1. View, filter, and save Product Permutation. \n 2. Synchronised with Product Category page and all common functionality moved into base and base table css, js, and python files.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -146,8 +146,8 @@ DROP TABLE IF EXISTS Shop_Product_Permutation_Temp;
|
||||
DROP TABLE IF EXISTS Shop_Product_Permutation_Audit;
|
||||
DROP TABLE IF EXISTS Shop_Product_Permutation;
|
||||
|
||||
DROP TABLE IF EXISTS Shop_Recurrence_Interval_Audit;
|
||||
DROP TABLE IF EXISTS Shop_Recurrence_Interval;
|
||||
DROP TABLE IF EXISTS Shop_Interval_Recurrence_Audit;
|
||||
DROP TABLE IF EXISTS Shop_Interval_Recurrence;
|
||||
|
||||
DROP TABLE IF EXISTS Shop_Product_Audit;
|
||||
DROP TABLE IF EXISTS Shop_Product;
|
||||
@@ -221,9 +221,14 @@ DROP TABLE IF EXISTS Shop_Product_Change_Set;
|
||||
DROP PROCEDURE IF EXISTS p_split;
|
||||
DROP PROCEDURE IF EXISTS p_clear_split_temp;
|
||||
|
||||
DROP FUNCTION IF EXISTS fn_shop_get_product_permutation_name;
|
||||
|
||||
DROP PROCEDURE IF EXISTS p_shop_user_eval;
|
||||
DROP PROCEDURE IF EXISTS p_clear_shop_user_eval_temp;
|
||||
|
||||
DROP PROCEDURE IF EXISTS p_shop_get_many_access_level;
|
||||
DROP PROCEDURE IF EXISTS p_shop_get_many_unit_measurement;
|
||||
|
||||
DROP PROCEDURE IF EXISTS p_shop_get_many_region;
|
||||
DROP PROCEDURE IF EXISTS p_shop_get_many_currency;
|
||||
|
||||
@@ -234,6 +239,7 @@ DROP PROCEDURE IF EXISTS p_shop_save_product;
|
||||
DROP PROCEDURE IF EXISTS p_shop_get_many_product;
|
||||
DROP PROCEDURE IF EXISTS p_shop_get_many_stripe_product_new;
|
||||
DROP PROCEDURE IF EXISTS p_shop_save_permutation;
|
||||
DROP PROCEDURE IF EXISTS p_shop_save_product_permutation;
|
||||
DROP PROCEDURE IF EXISTS p_shop_get_many_product_variation;
|
||||
DROP PROCEDURE IF EXISTS p_shop_get_many_stock_item;
|
||||
DROP PROCEDURE IF EXISTS p_shop_get_many_product_price_and_discount_and_delivery_option;
|
||||
|
||||
@@ -10,6 +10,7 @@ CREATE TABLE IF NOT EXISTS Shop_Unit_Measurement (
|
||||
name_singular VARCHAR(255) NOT NULL,
|
||||
name_plural VARCHAR(256) NOT NULL,
|
||||
symbol VARCHAR(50) NOT NULL,
|
||||
symbol_is_suffix_not_prefix BIT NOT NULL DEFAULT 1,
|
||||
is_base_unit BIT NOT NULL DEFAULT 0,
|
||||
is_unit_of_distance BIT NOT NULL DEFAULT 0,
|
||||
is_unit_of_mass BIT NOT NULL DEFAULT 0,
|
||||
|
||||
@@ -25,11 +25,11 @@ CREATE TABLE IF NOT EXISTS Shop_Product (
|
||||
quantity_step FLOAT,
|
||||
quantity_stock FLOAT,
|
||||
is_subscription BIT,
|
||||
id_recurrence_interval INT,
|
||||
CONSTRAINT FK_Shop_Product_id_recurrence_interval
|
||||
FOREIGN KEY (id_recurrence_interval)
|
||||
REFERENCES Shop_Recurrence_Interval(id_interval),
|
||||
count_recurrence_interval INT,
|
||||
id_unit_measurement_interval_recurrence INT,
|
||||
CONSTRAINT FK_Shop_Product_id_unit_measurement_interval_recurrence
|
||||
FOREIGN KEY (id_unit_measurement_interval_recurrence)
|
||||
REFERENCES Shop_Interval_Recurrence(id_interval),
|
||||
count_interval_recurrence INT,
|
||||
*/
|
||||
id_access_level_required INT NOT NULL,
|
||||
CONSTRAINT FK_Shop_Product_id_access_level_required
|
||||
|
||||
@@ -18,26 +18,30 @@ CREATE TABLE IF NOT EXISTS Shop_Product_Permutation (
|
||||
id_currency_cost INT NOT NULL,
|
||||
profit_local_min FLOAT NOT NULL,
|
||||
-- id_currency_profit_min INT NOT NULL,
|
||||
latency_manufacture INT NOT NULL,
|
||||
latency_manufacture_days INT NOT NULL,
|
||||
id_unit_measurement_quantity INT NOT NULL,
|
||||
CONSTRAINT FK_Shop_Product_Permutation_id_unit_quantity
|
||||
FOREIGN KEY (id_unit_measurement_quantity)
|
||||
REFERENCES Shop_Unit_Measurement(id_unit_measurement),
|
||||
count_unit_measurement_per_quantity_step FLOAT NOT NULL,
|
||||
quantity_min FLOAT NOT NULL,
|
||||
quantity_max FLOAT NOT NULL,
|
||||
quantity_step FLOAT NOT NULL,
|
||||
quantity_stock FLOAT NOT NULL,
|
||||
is_subscription BIT NOT NULL,
|
||||
id_interval_recurrence INT,
|
||||
CONSTRAINT FK_Shop_Product_Permutation_id_interval_recurrence
|
||||
FOREIGN KEY (id_interval_recurrence)
|
||||
id_unit_measurement_interval_recurrence INT,
|
||||
CONSTRAINT FK_Shop_Product_Permutation_id_unit_interval_recurrence
|
||||
FOREIGN KEY (id_unit_measurement_interval_recurrence)
|
||||
REFERENCES Shop_Unit_Measurement(id_unit_measurement),
|
||||
/*
|
||||
CONSTRAINT CHECK_FK_Shop_Product_Permutation_id_interval_recurrence
|
||||
CHECK (id_interval_recurrence IN (SELECT id_unit_measurement FROM Shop_Unit_Measurement WHERE is_unit_of_time = 1)),
|
||||
CONSTRAINT CHECK_FK_Shop_Product_Permutation_id_unit_measurement_interval_recurrence
|
||||
CHECK (id_unit_measurement_interval_recurrence IN (SELECT id_unit_measurement FROM Shop_Unit_Measurement WHERE is_unit_of_time = 1)),
|
||||
*/
|
||||
count_interval_recurrence INT,
|
||||
id_stripe_product VARCHAR(100) NULL,
|
||||
does_expire_faster_once_unsealed BIT NOT NULL DEFAULT 0,
|
||||
id_interval_expiration_unsealed INT,
|
||||
CONSTRAINT FK_Shop_Product_Permutation_id_interval_expiration_unsealed
|
||||
FOREIGN KEY (id_interval_expiration_unsealed)
|
||||
id_unit_measurement_interval_expiration_unsealed INT,
|
||||
CONSTRAINT FK_Shop_Product_Permutation_id_unit_interval_expiration_unsealed
|
||||
FOREIGN KEY (id_unit_measurement_interval_expiration_unsealed)
|
||||
REFERENCES Shop_Unit_Measurement(id_unit_measurement),
|
||||
/*
|
||||
CONSTRAINT CHECK_FK_Shop_Product_Permutation_id_interval_expiration_unsealed
|
||||
|
||||
@@ -16,27 +16,29 @@ CREATE TABLE IF NOT EXISTS Shop_Product_Permutation_Temp (
|
||||
cost_local FLOAT NOT NULL,
|
||||
id_currency_cost INT NOT NULL,
|
||||
profit_local_min FLOAT NOT NULL,
|
||||
latency_manufacture INT NOT NULL,
|
||||
latency_manufacture_days INT NOT NULL,
|
||||
id_unit_measurement_quantity INT NOT NULL,
|
||||
CONSTRAINT FK_Shop_Product_Permutation_Temp_id_unit_quantity
|
||||
FOREIGN KEY (id_unit_measurement_quantity)
|
||||
REFERENCES Shop_Unit_Measurement(id_unit_measurement),
|
||||
count_unit_measurement_per_quantity_step FLOAT NOT NULL,
|
||||
quantity_min FLOAT NOT NULL,
|
||||
quantity_max FLOAT NOT NULL,
|
||||
quantity_step FLOAT NOT NULL,
|
||||
quantity_stock FLOAT NOT NULL,
|
||||
quantity_stock FLOAT NULL,
|
||||
is_subscription BIT NOT NULL,
|
||||
id_interval_recurrence INT,
|
||||
CONSTRAINT FK_Shop_Product_Permutation_Temp_id_interval_recurrence
|
||||
FOREIGN KEY (id_interval_recurrence)
|
||||
id_unit_measurement_interval_recurrence INT,
|
||||
CONSTRAINT FK_Shop_Product_Permutation_Temp_id_unit_recurrence
|
||||
FOREIGN KEY (id_unit_measurement_interval_recurrence)
|
||||
REFERENCES Shop_Unit_Measurement(id_unit_measurement),
|
||||
count_interval_recurrence INT,
|
||||
id_stripe_product VARCHAR(100) NULL,
|
||||
does_expire_faster_once_unsealed BIT NOT NULL DEFAULT 0,
|
||||
id_interval_expiration_unsealed INT,
|
||||
CONSTRAINT FK_Shop_Product_Permutation_Temp_id_interval_expiration_unsealed
|
||||
FOREIGN KEY (id_interval_expiration_unsealed)
|
||||
id_unit_measurement_interval_expiration_unsealed INT,
|
||||
CONSTRAINT FK_Shop_Product_Permutation_Temp_id_unit_expiration
|
||||
FOREIGN KEY (id_unit_measurement_interval_expiration_unsealed)
|
||||
REFERENCES Shop_Unit_Measurement(id_unit_measurement),
|
||||
count_interval_expiration_unsealed INT,
|
||||
active BIT NOT NULL DEFAULT 1,
|
||||
display_order INT NOT NULL,
|
||||
created_on TIMESTAMP,
|
||||
created_by INT,
|
||||
-- display_order INT NOT NULL,
|
||||
guid BINARY(36)
|
||||
);
|
||||
|
||||
@@ -62,11 +62,11 @@ BEGIN
|
||||
SIGNAL SQLSTATE '45000'
|
||||
SET MESSAGE_TEXT = 'Product must have subscription status or variations (with subscription statuses).';
|
||||
END IF;
|
||||
IF ISNULL(NEW.id_recurrence_interval) THEN
|
||||
IF ISNULL(NEW.id_unit_measurement_interval_recurrence) THEN
|
||||
SIGNAL SQLSTATE '45000'
|
||||
SET MESSAGE_TEXT = 'Product must have recurrence interval or variations (with recurrence intervals).';
|
||||
END IF;
|
||||
IF ISNULL(NEW.count_recurrence_interval) THEN
|
||||
IF ISNULL(NEW.count_interval_recurrence) THEN
|
||||
SIGNAL SQLSTATE '45000'
|
||||
SET MESSAGE_TEXT = 'Product must have recurrence interval count or variations (with recurrence interval counts).';
|
||||
END IF;
|
||||
@@ -136,13 +136,13 @@ BEGIN
|
||||
SELECT NEW.id_product, 'is_subscription', CONVERT(CONVERT(OLD.is_subscription, SIGNED), CHAR), CONVERT(CONVERT(NEW.is_subscription, SIGNED), CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.is_subscription <=> NEW.is_subscription
|
||||
UNION
|
||||
# Changed id_recurrence_interval
|
||||
SELECT NEW.id_product, 'id_recurrence_interval', CONVERT(OLD.id_recurrence_interval, CHAR), CONVERT(NEW.id_recurrence_interval, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.id_recurrence_interval <=> NEW.id_recurrence_interval
|
||||
# Changed id_unit_measurement_interval_recurrence
|
||||
SELECT NEW.id_product, 'id_unit_measurement_interval_recurrence', CONVERT(OLD.id_unit_measurement_interval_recurrence, CHAR), CONVERT(NEW.id_unit_measurement_interval_recurrence, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.id_unit_measurement_interval_recurrence <=> NEW.id_unit_measurement_interval_recurrence
|
||||
UNION
|
||||
# Changed count_recurrence_interval
|
||||
SELECT NEW.id_product, 'count_recurrence_interval', CONVERT(OLD.count_recurrence_interval, CHAR), CONVERT(NEW.count_recurrence_interval, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.count_recurrence_interval <=> NEW.count_recurrence_interval
|
||||
# Changed count_interval_recurrence
|
||||
SELECT NEW.id_product, 'count_interval_recurrence', CONVERT(OLD.count_interval_recurrence, CHAR), CONVERT(NEW.count_interval_recurrence, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.count_interval_recurrence <=> NEW.count_interval_recurrence
|
||||
UNION
|
||||
# Changed id_stripe_product
|
||||
SELECT NEW.id_product, 'id_stripe_product', OLD.id_stripe_product, NEW.id_stripe_product, NEW.id_change_set
|
||||
|
||||
@@ -29,16 +29,16 @@ BEGIN
|
||||
END IF;
|
||||
|
||||
IF (NOT (
|
||||
NEW.id_interval_recurrence IS NULL
|
||||
OR NEW.id_interval_recurrence NOT IN (SELECT id_unit_measurement FROM Shop_Unit_Measurement WHERE is_unit_of_time = 1)
|
||||
NEW.id_unit_measurement_interval_recurrence IS NULL
|
||||
OR NEW.id_unit_measurement_interval_recurrence NOT IN (SELECT id_unit_measurement FROM Shop_Unit_Measurement WHERE is_unit_of_time = 1)
|
||||
)) THEN
|
||||
SIGNAL SQLSTATE '45000'
|
||||
SET MESSAGE_TEXT = 'Recurrence interval ID must be a unit of time.';
|
||||
END IF;
|
||||
|
||||
IF (NOT (
|
||||
NEW.id_interval_expiration_unsealed IS NULL
|
||||
OR NEW.id_interval_expiration_unsealed NOT IN (SELECT id_unit_measurement FROM Shop_Unit_Measurement WHERE is_unit_of_time = 1)
|
||||
NEW.id_unit_measurement_interval_expiration_unsealed IS NULL
|
||||
OR NEW.id_unit_measurement_interval_expiration_unsealed NOT IN (SELECT id_unit_measurement FROM Shop_Unit_Measurement WHERE is_unit_of_time = 1)
|
||||
)) THEN
|
||||
SIGNAL SQLSTATE '45000'
|
||||
SET MESSAGE_TEXT = 'Unsealed expiration interval ID must be a unit of time.';
|
||||
@@ -77,11 +77,11 @@ BEGIN
|
||||
SELECT NEW.id_permutation, 'id_currency_cost', CONVERT(OLD.id_currency_cost, CHAR), CONVERT(NEW.id_currency_cost, CHAR), NEW.id_change_set
|
||||
WHERE NOT (OLD.id_currency_cost <=> NEW.id_currency_cost)
|
||||
UNION
|
||||
/*
|
||||
# Changed profit_local_min
|
||||
SELECT NEW.id_permutation, 'profit_local_min', CONVERT(OLD.profit_local_min, CHAR), CONVERT(NEW.profit_local_min, CHAR), NEW.id_change_set
|
||||
WHERE NOT (OLD.profit_local_min <=> NEW.profit_local_min)
|
||||
UNION
|
||||
/*
|
||||
# Changed id_currency_profit_min
|
||||
SELECT NEW.id_permutation, 'id_currency_profit_min', CONVERT(OLD.id_currency_profit_min, CHAR), CONVERT(NEW.id_currency_profit_min, CHAR), NEW.id_change_set
|
||||
WHERE NOT (OLD.id_currency_profit_min <=> NEW.id_currency_profit_min)
|
||||
@@ -93,36 +93,40 @@ BEGIN
|
||||
WHERE NOT (OLD.price_GBP_min <=> NEW.price_GBP_min)
|
||||
UNION
|
||||
*/
|
||||
# Changed latency_manufacture
|
||||
SELECT NEW.id_product, 'latency_manufacture', CONVERT(OLD.latency_manufacture, CHAR), CONVERT(NEW.latency_manufacture, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.latency_manufacture <=> NEW.latency_manufacture
|
||||
# Changed latency_manufacture_days
|
||||
SELECT NEW.id_permutation, 'latency_manufacture_days', CONVERT(OLD.latency_manufacture_days, CHAR), CONVERT(NEW.latency_manufacture_days, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.latency_manufacture_days <=> NEW.latency_manufacture_days
|
||||
UNION
|
||||
# Changed id_unit_measurement_quantity
|
||||
SELECT NEW.id_permutation, 'id_unit_measurement_quantity', CONVERT(OLD.id_unit_measurement_quantity, CHAR), CONVERT(NEW.id_unit_measurement_quantity, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.id_unit_measurement_quantity <=> NEW.id_unit_measurement_quantity
|
||||
UNION
|
||||
# Changed count_unit_measurement_per_quantity_step
|
||||
SELECT NEW.id_permutation, 'count_unit_measurement_per_quantity_step', CONVERT(OLD.count_unit_measurement_per_quantity_step, CHAR), CONVERT(NEW.count_unit_measurement_per_quantity_step, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.count_unit_measurement_per_quantity_step <=> NEW.count_unit_measurement_per_quantity_step
|
||||
UNION
|
||||
# Changed quantity_min
|
||||
SELECT NEW.id_product, 'quantity_min', CONVERT(OLD.quantity_min, CHAR), CONVERT(NEW.quantity_min, CHAR), NEW.id_change_set
|
||||
SELECT NEW.id_permutation, 'quantity_min', CONVERT(OLD.quantity_min, CHAR), CONVERT(NEW.quantity_min, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.quantity_min <=> NEW.quantity_min
|
||||
UNION
|
||||
# Changed quantity_max
|
||||
SELECT NEW.id_product, 'quantity_max', CONVERT(OLD.quantity_max, CHAR), CONVERT(NEW.quantity_max, CHAR), NEW.id_change_set
|
||||
SELECT NEW.id_permutation, 'quantity_max', CONVERT(OLD.quantity_max, CHAR), CONVERT(NEW.quantity_max, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.quantity_max <=> NEW.quantity_max
|
||||
UNION
|
||||
# Changed quantity_step
|
||||
SELECT NEW.id_product, 'quantity_step', CONVERT(OLD.quantity_step, CHAR), CONVERT(NEW.quantity_step, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.quantity_step <=> NEW.quantity_step
|
||||
UNION
|
||||
# Changed quantity_stock
|
||||
SELECT NEW.id_product, 'quantity_stock', CONVERT(OLD.quantity_stock, CHAR), CONVERT(NEW.quantity_stock, CHAR), NEW.id_change_set
|
||||
SELECT NEW.id_permutation, 'quantity_stock', CONVERT(OLD.quantity_stock, CHAR), CONVERT(NEW.quantity_stock, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.quantity_stock <=> NEW.quantity_stock
|
||||
UNION
|
||||
# Changed is_subscription
|
||||
SELECT NEW.id_product, 'is_subscription', CONVERT(CONVERT(OLD.is_subscription, SIGNED), CHAR), CONVERT(CONVERT(NEW.is_subscription, SIGNED), CHAR), NEW.id_change_set
|
||||
SELECT NEW.id_permutation, 'is_subscription', CONVERT(CONVERT(OLD.is_subscription, SIGNED), CHAR), CONVERT(CONVERT(NEW.is_subscription, SIGNED), CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.is_subscription <=> NEW.is_subscription
|
||||
UNION
|
||||
# Changed id_interval_recurrence
|
||||
SELECT NEW.id_product, 'id_interval_recurrence', CONVERT(OLD.id_interval_recurrence, CHAR), CONVERT(NEW.id_interval_recurrence, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.id_interval_recurrence <=> NEW.id_interval_recurrence
|
||||
# Changed id_unit_measurement_interval_recurrence
|
||||
SELECT NEW.id_permutation, 'id_unit_measurement_interval_recurrence', CONVERT(OLD.id_unit_measurement_interval_recurrence, CHAR), CONVERT(NEW.id_unit_measurement_interval_recurrence, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.id_unit_measurement_interval_recurrence <=> NEW.id_unit_measurement_interval_recurrence
|
||||
UNION
|
||||
# Changed count_interval_recurrence
|
||||
SELECT NEW.id_product, 'count_interval_recurrence', CONVERT(OLD.count_interval_recurrence, CHAR), CONVERT(NEW.count_interval_recurrence, CHAR), NEW.id_change_set
|
||||
SELECT NEW.id_permutation, 'count_interval_recurrence', CONVERT(OLD.count_interval_recurrence, CHAR), CONVERT(NEW.count_interval_recurrence, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.count_interval_recurrence <=> NEW.count_interval_recurrence
|
||||
UNION
|
||||
# Changed id_stripe_product
|
||||
@@ -130,24 +134,26 @@ BEGIN
|
||||
WHERE NOT (OLD.id_stripe_product <=> NEW.id_stripe_product)
|
||||
UNION
|
||||
# Changed does_expire_faster_once_unsealed
|
||||
SELECT NEW.id_product, 'does_expire_faster_once_unsealed', CONVERT(OLD.does_expire_faster_once_unsealed, CHAR), CONVERT(NEW.does_expire_faster_once_unsealed, CHAR), NEW.id_change_set
|
||||
SELECT NEW.id_permutation, 'does_expire_faster_once_unsealed', CONVERT(OLD.does_expire_faster_once_unsealed, CHAR), CONVERT(NEW.does_expire_faster_once_unsealed, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.does_expire_faster_once_unsealed <=> NEW.does_expire_faster_once_unsealed
|
||||
UNION
|
||||
# Changed id_interval_expiration_unsealed
|
||||
SELECT NEW.id_product, 'id_interval_expiration_unsealed', CONVERT(OLD.id_interval_expiration_unsealed, CHAR), CONVERT(NEW.id_interval_expiration_unsealed, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.id_interval_expiration_unsealed <=> NEW.id_interval_expiration_unsealed
|
||||
# Changed id_unit_measurement_interval_expiration_unsealed
|
||||
SELECT NEW.id_permutation, 'id_unit_measurement_interval_expiration_unsealed', CONVERT(OLD.id_unit_measurement_interval_expiration_unsealed, CHAR), CONVERT(NEW.id_unit_measurement_interval_expiration_unsealed, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.id_unit_measurement_interval_expiration_unsealed <=> NEW.id_unit_measurement_interval_expiration_unsealed
|
||||
UNION
|
||||
# Changed count_interval_expiration_unsealed
|
||||
SELECT NEW.id_product, 'count_interval_expiration_unsealed', CONVERT(OLD.count_interval_expiration_unsealed, CHAR), CONVERT(NEW.count_interval_expiration_unsealed, CHAR), NEW.id_change_set
|
||||
SELECT NEW.id_permutation, 'count_interval_expiration_unsealed', CONVERT(OLD.count_interval_expiration_unsealed, CHAR), CONVERT(NEW.count_interval_expiration_unsealed, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.count_interval_expiration_unsealed <=> NEW.count_interval_expiration_unsealed
|
||||
UNION
|
||||
# Changed active
|
||||
SELECT NEW.id_permutation, 'active', CONVERT(CONVERT(OLD.active, SIGNED), CHAR), CONVERT(CONVERT(NEW.active, SIGNED), CHAR), NEW.id_change_set
|
||||
WHERE NOT (OLD.active <=> NEW.active)
|
||||
UNION
|
||||
/*
|
||||
UNION
|
||||
# Changed display_order
|
||||
SELECT NEW.id_permutation, 'display_order', CONVERT(OLD.display_order, CHAR), CONVERT(NEW.display_order, CHAR), NEW.id_change_set
|
||||
WHERE NOT (OLD.display_order <=> NEW.display_order)
|
||||
*/
|
||||
;
|
||||
END //
|
||||
DELIMITER ;;
|
||||
|
||||
33
static/MySQL/6206_fn_shop_get_product_permutation_name.sql
Normal file
33
static/MySQL/6206_fn_shop_get_product_permutation_name.sql
Normal file
@@ -0,0 +1,33 @@
|
||||
|
||||
DROP FUNCTION IF EXISTS fn_shop_get_product_permutation_name;
|
||||
|
||||
DELIMITER //
|
||||
|
||||
CREATE FUNCTION fn_shop_get_product_permutation_name(id_product_permutation INT)
|
||||
RETURNS VARCHAR(4000)
|
||||
DETERMINISTIC
|
||||
BEGIN
|
||||
DECLARE name VARCHAR(4000);
|
||||
|
||||
SET name := (
|
||||
SELECT
|
||||
CONCAT(
|
||||
P.name
|
||||
, CASE WHEN P.has_variations = 1 THEN
|
||||
CONCAT(' - ', GROUP_CONCAT(CONCAT(VT.name, ': ', V.name) SEPARATOR ', '))
|
||||
ELSE '' END
|
||||
)
|
||||
FROM Shop_Product_Permutation PP
|
||||
INNER JOIN Shop_Product P ON PP.id_product = P.id_product
|
||||
INNER JOIN Shop_Product_Permutation_Variation_Link PPVL ON PP.id_permutation = PPVL.id_permutation
|
||||
INNER JOIN Shop_Variation V ON PPVL.id_variation = V.id_variation
|
||||
INNER JOIN Shop_Variation_Type VT ON V.id_type = VT.id_type
|
||||
WHERE PP.id_permutation = id_product_permutation
|
||||
GROUP BY P.id_product, P.name, P.has_variations, VT.display_order, VT.name, V.display_order, V.name
|
||||
LIMIT 1
|
||||
);
|
||||
|
||||
RETURN name;
|
||||
END //
|
||||
|
||||
DELIMITER ;
|
||||
@@ -16,19 +16,18 @@ DROP PROCEDURE IF EXISTS p_shop_get_many_access_level;
|
||||
|
||||
DELIMITER //
|
||||
CREATE PROCEDURE p_shop_get_many_access_level (
|
||||
IN a_id_user INT,
|
||||
IN a_get_inactive_access_level BIT
|
||||
)
|
||||
BEGIN
|
||||
SET a_get_inactive_access_level = IFNULL(a_get_inactive_access_level, 0);
|
||||
|
||||
SELECT
|
||||
AL.id_access_level,
|
||||
AL.code,
|
||||
AL.name,
|
||||
AL.active,
|
||||
AL.priority,
|
||||
AL.display_order
|
||||
AL.id_access_level
|
||||
, AL.code
|
||||
, AL.name
|
||||
, AL.active
|
||||
, AL.priority
|
||||
, AL.display_order
|
||||
FROM Shop_Access_Level AL
|
||||
WHERE
|
||||
a_get_inactive_access_level = 1
|
||||
|
||||
@@ -27,9 +27,10 @@ BEGIN
|
||||
C.id_currency,
|
||||
C.code,
|
||||
C.name,
|
||||
C.symbol,
|
||||
C.factor_from_GBP,
|
||||
C.active,
|
||||
C.display_order
|
||||
C.display_order,
|
||||
C.active
|
||||
FROM Shop_Currency C
|
||||
WHERE a_get_inactive_currency
|
||||
OR C.active
|
||||
|
||||
41
static/MySQL/7122_p_shop_get_many_unit_measurement.sql
Normal file
41
static/MySQL/7122_p_shop_get_many_unit_measurement.sql
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
-- Clear previous proc
|
||||
DROP PROCEDURE IF EXISTS p_shop_get_many_unit_measurement;
|
||||
|
||||
|
||||
DELIMITER //
|
||||
CREATE PROCEDURE p_shop_get_many_unit_measurement (
|
||||
IN a_get_inactive_unit_measurement BIT
|
||||
)
|
||||
BEGIN
|
||||
SET a_get_inactive_unit_measurement := IFNULL(a_get_inactive_unit_measurement, 0);
|
||||
|
||||
SELECT
|
||||
UM.id_unit_measurement,
|
||||
UM.name_singular,
|
||||
UM.name_plural,
|
||||
UM.symbol,
|
||||
UM.symbol_is_suffix_not_prefix,
|
||||
UM.is_base_unit,
|
||||
UM.is_unit_of_distance,
|
||||
UM.is_unit_of_mass,
|
||||
UM.is_unit_of_time,
|
||||
UM.is_unit_of_volume,
|
||||
UM.active
|
||||
FROM Shop_Unit_Measurement UM
|
||||
WHERE
|
||||
a_get_inactive_unit_measurement = 1
|
||||
OR UM.active = 1
|
||||
;
|
||||
END //
|
||||
DELIMITER ;;
|
||||
|
||||
|
||||
/*
|
||||
CALL p_shop_get_many_unit_measurement (
|
||||
0 # a_get_inactive_unit_measurement
|
||||
);
|
||||
|
||||
select *
|
||||
from shop_unit_measurement
|
||||
*/
|
||||
@@ -1,7 +1,5 @@
|
||||
|
||||
|
||||
|
||||
|
||||
-- Clear previous proc
|
||||
DROP PROCEDURE IF EXISTS p_save_category;
|
||||
DROP PROCEDURE IF EXISTS p_shop_save_category;
|
||||
|
||||
@@ -95,11 +95,11 @@ BEGIN
|
||||
);
|
||||
|
||||
CREATE TEMPORARY TABLE tmp_Permutation (
|
||||
-- id_category INT NOT NULL,
|
||||
id_product INT NOT NULL,
|
||||
id_permutation INT NULL,
|
||||
active BIT NOT NULL,
|
||||
display_order INT NOT NULL
|
||||
id_permutation INT NULL
|
||||
-- id_category INT NOT NULL,
|
||||
, id_product INT NOT NULL
|
||||
, active BIT NOT NULL
|
||||
-- , display_order INT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TEMPORARY TABLE tmp_Image (
|
||||
@@ -178,18 +178,18 @@ BEGIN
|
||||
;
|
||||
|
||||
INSERT INTO tmp_Permutation (
|
||||
id_permutation
|
||||
-- id_category,
|
||||
id_product,
|
||||
id_permutation,
|
||||
active,
|
||||
display_order
|
||||
, id_product
|
||||
, active
|
||||
-- , display_order
|
||||
)
|
||||
SELECT
|
||||
PP.id_permutation
|
||||
-- P.id_category,
|
||||
PP.id_product,
|
||||
PP.id_permutation,
|
||||
PP.active,
|
||||
PP.display_order
|
||||
, PP.id_product
|
||||
, PP.active
|
||||
-- , RANK() OVER (ORDER BY VT.display_order, V.display_order)
|
||||
FROM Shop_Product_Permutation PP
|
||||
INNER JOIN tmp_Product t_P ON PP.id_product = t_P.id_product
|
||||
WHERE (
|
||||
@@ -370,19 +370,35 @@ BEGIN
|
||||
PP.id_currency_cost,
|
||||
C.code AS code_currency_cost,
|
||||
C.symbol AS symbol_currency_cost,
|
||||
PP.profit_local_min,
|
||||
PP.latency_manufacture,
|
||||
-- PP.profit_local_min,
|
||||
PP.latency_manufacture_days,
|
||||
PP.id_unit_measurement_quantity,
|
||||
UM_Q.symbol AS symbol_unit_measurement_quantity,
|
||||
UM_Q.symbol_is_suffix_not_prefix AS symbol_is_suffix_not_prefix_unit_measurement_quantity,
|
||||
UM_Q.name_singular AS name_singular_unit_measurement_quantity,
|
||||
UM_Q.name_plural AS name_plural_unit_measurement_quantity,
|
||||
PP.count_unit_measurement_per_quantity_step,
|
||||
PP.quantity_min,
|
||||
PP.quantity_max,
|
||||
PP.quantity_step,
|
||||
PP.quantity_stock,
|
||||
PP.id_stripe_product,
|
||||
PP.is_subscription,
|
||||
UM.name_singular AS name_recurrence_interval,
|
||||
UM.name_plural AS name_plural_recurrence_interval,
|
||||
PP.id_unit_measurement_interval_recurrence,
|
||||
UM_R.symbol AS symbol_unit_measurement_interval_recurrence,
|
||||
UM_R.symbol_is_suffix_not_prefix AS symbol_is_suffix_not_prefix_unit_measurement_interval_recurrence,
|
||||
UM_R.name_singular AS name_singular_unit_measurement_interval_recurrence,
|
||||
UM_R.name_plural AS name_plural_unit_measurement_interval_recurrence,
|
||||
PP.count_interval_recurrence,
|
||||
PP.id_stripe_product,
|
||||
PP.does_expire_faster_once_unsealed,
|
||||
PP.id_unit_measurement_interval_expiration_unsealed,
|
||||
UM_X.symbol AS symbol_unit_measurement_interval_expiration_unsealed,
|
||||
UM_X.symbol_is_suffix_not_prefix AS symbol_is_suffix_not_prefix_unit_measurement_interval_expiration_unsealed,
|
||||
UM_X.name_singular AS name_singular_unit_measurement_interval_expiration_unsealed,
|
||||
UM_X.name_plural AS name_plural_unit_measurement_interval_expiration_unsealed,
|
||||
PP.count_interval_expiration_unsealed,
|
||||
NOT ISNULL(PPVL.id_permutation) AS has_variations,
|
||||
PP.active,
|
||||
PP.display_order,
|
||||
-- PP.display_order,
|
||||
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
|
||||
@@ -391,26 +407,28 @@ BEGIN
|
||||
INNER JOIN tmp_Product t_P ON t_PP.id_product = t_P.id_product
|
||||
INNER JOIN Shop_Product P ON t_PP.id_product = P.id_product
|
||||
INNER JOIN Shop_Product_Category PC ON P.id_category = PC.id_category
|
||||
-- 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
|
||||
LEFT JOIN Shop_Product_Permutation_Variation_Link PPVL ON PP.id_permutation = PPVL.id_permutation
|
||||
LEFT JOIN Shop_Unit_Measurement UM_Q ON PP.id_unit_measurement_quantity = UM_Q.id_unit_measurement
|
||||
LEFT JOIN Shop_Unit_Measurement UM_R ON PP.id_unit_measurement_interval_recurrence = UM_R.id_unit_measurement
|
||||
LEFT JOIN Shop_Unit_Measurement UM_X ON PP.id_unit_measurement_interval_expiration_unsealed = UM_X.id_unit_measurement
|
||||
INNER JOIN Shop_Currency C ON PP.id_currency_cost = C.id_currency
|
||||
GROUP BY PC.id_category, P.id_product, PP.id_permutation, t_P.can_view, t_P.can_edit, t_P.can_admin
|
||||
ORDER BY PC.display_order, P.display_order, PP.display_order
|
||||
ORDER BY PC.display_order, P.display_order -- , t_PP.display_order
|
||||
;
|
||||
|
||||
# Variations
|
||||
SELECT
|
||||
V.id_variation
|
||||
, V.id_type
|
||||
, V.code AS code_variation
|
||||
, V.name AS name_variation
|
||||
, V.display_order AS display_order_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.display_order AS display_order_variation_type
|
||||
, VT.active AS active_variation_type
|
||||
, VT.display_order
|
||||
, t_P.id_product
|
||||
, t_PP.id_permutation
|
||||
, t_C.id_category
|
||||
@@ -458,7 +476,7 @@ BEGIN
|
||||
INNER JOIN tmp_Permutation t_PP ON t_I.id_permutation = t_PP.id_permutation
|
||||
INNER JOIN tmp_Product t_P ON t_PP.id_product = t_P.id_product
|
||||
INNER JOIN tmp_Category t_C ON t_P.id_category = t_C.id_category
|
||||
ORDER BY t_C.display_order, t_P.display_order, t_PP.display_order, I.display_order
|
||||
ORDER BY t_C.display_order, t_P.display_order, I.display_order
|
||||
;
|
||||
|
||||
# Errors
|
||||
@@ -514,7 +532,7 @@ DELIMITER ;;
|
||||
CALL partsltd_prod.p_shop_get_many_product (
|
||||
1 #'auth0|6582b95c895d09a70ba10fef', # a_id_user
|
||||
, 1 # a_get_all_product_category
|
||||
, 1 # a_get_inactive_product_category
|
||||
, 0 # a_get_inactive_product_category
|
||||
, '' # a_ids_product_category
|
||||
, 1 # a_get_all_product
|
||||
, 0 # a_get_inactive_product
|
||||
@@ -525,7 +543,7 @@ CALL partsltd_prod.p_shop_get_many_product (
|
||||
, 1 # a_get_all_image
|
||||
, 0 # a_get_inactive_image
|
||||
, '' # a_ids_image
|
||||
, 1 # a_get_products_quantity_stock_below_minimum
|
||||
, 0 # a_get_products_quantity_stock_below_minimum
|
||||
);
|
||||
|
||||
select * FROM Shop_User_Eval_Temp;
|
||||
|
||||
@@ -1,605 +0,0 @@
|
||||
|
||||
|
||||
|
||||
|
||||
-- Clear previous proc
|
||||
DROP PROCEDURE IF EXISTS p_shop_save_permutation;
|
||||
|
||||
DROP TABLE IF EXISTS tmp_Shop_Manufacturing_Purchase_Order_Product_Link;
|
||||
DROP TABLE IF EXISTS tmp_Msg_Error;
|
||||
|
||||
DELIMITER //
|
||||
CREATE PROCEDURE p_shop_save_permutation (
|
||||
IN a_guid VARCHAR(500),
|
||||
IN a_id_user INT,
|
||||
IN a_id_order INT,
|
||||
-- IN a_id_supplier_ordered INT,
|
||||
IN a_id_currency_cost INT,
|
||||
IN a_active BIT,
|
||||
IN a_comment VARCHAR(500)
|
||||
)
|
||||
BEGIN
|
||||
DECLARE v_id_error_type_bad_data INT;
|
||||
DECLARE v_code_error_type_bad_data VARCHAR(50);
|
||||
DECLARE v_id_error_type_no_permission INT;
|
||||
DECLARE v_code_error_type_no_permission VARCHAR(50);
|
||||
DECLARE v_guid_permission BINARY(36);
|
||||
-- DECLARE v_id_user VARCHAR(100);
|
||||
DECLARE v_id_permission_manufacturing_purchase_order INT;
|
||||
DECLARE v_id_access_level_EDIT INT;
|
||||
DECLARE v_ids_product VARCHAR(4000);
|
||||
DECLARE v_ids_product_no_permission VARCHAR(4000);
|
||||
-- DECLARE v_id_order_new INT;
|
||||
DECLARE v_id_change_set INT;
|
||||
DECLARE v_is_new_manufacturing_purchase_order BIT;
|
||||
|
||||
SET SESSION sql_mode = sys.list_drop(@@session.sql_mode, 'ONLY_FULL_GROUP_BY');
|
||||
|
||||
SET v_code_error_type_bad_data = 'BAD_DATA';
|
||||
SET v_id_error_type_bad_data := (SELECT id_type FROM Shop_Msg_Error_Type WHERE code = v_code_error_type_bad_data LIMIT 1);
|
||||
SET v_code_error_type_no_permission = 'NO_PERMISSION';
|
||||
SET v_id_error_type_no_permission := (SELECT id_type FROM Shop_Msg_Error_Type WHERE code = v_code_error_type_no_permission LIMIT 1);
|
||||
SET v_guid_permission = UUID();
|
||||
-- SET v_id_user = CURRENT_USER();
|
||||
SET v_id_permission_manufacturing_purchase_order := (SELECT id_permission FROM Shop_Permission WHERE code = 'STORE_MANUFACTURING_PURCHASE_ORDER' LIMIT 1);
|
||||
SET v_id_access_level_EDIT := (SELECT id_access_level FROM Shop_Access_Level WHERE code = 'EDIT');
|
||||
|
||||
-- Argument default values
|
||||
IF a_guid IS NULL THEN
|
||||
SET a_guid = UUID();
|
||||
END IF;
|
||||
IF a_active IS NULL THEN
|
||||
SET a_active = 0;
|
||||
END IF;
|
||||
|
||||
-- Temporary tables
|
||||
/*
|
||||
CREATE TABLE tmp_Shop_Supplier_Purchase_Order (
|
||||
id_order INT NOT NULL PRIMARY KEY,
|
||||
id_supplier_ordered INT NOT NULL,
|
||||
CONSTRAINT FK_tmp_Shop_Supplier_Purchase_Order_id_supplier_ordered
|
||||
FOREIGN KEY (id_supplier_ordered)
|
||||
REFERENCES Shop_Supplier(id_supplier),
|
||||
cost_total_local FLOAT NOT NULL,
|
||||
id_currency_cost INT NOT NULL
|
||||
);
|
||||
*/
|
||||
|
||||
CREATE TABLE tmp_Shop_Manufacturing_Purchase_Order_Product_Link (
|
||||
id_link INT NOT NULL PRIMARY KEY,
|
||||
id_order INT NOT NULL,
|
||||
/*
|
||||
CONSTRAINT FK_tmp_Supplier_Purchase_Order_Product_Link_id_order
|
||||
FOREIGN KEY (id_order)
|
||||
REFERENCES Shop_Manufacturing_Purchase_Order(id_order),
|
||||
*/
|
||||
id_permutation INT NOT NULL,
|
||||
CONSTRAINT FK_tmp_Manuf_Purch_Order_Product_Link_id_permutation
|
||||
FOREIGN KEY (id_permutation)
|
||||
REFERENCES Shop_Product_Permutation(id_permutation),
|
||||
cost_total_local FLOAT NOT NULL,
|
||||
id_currency_cost INT NOT NULL,
|
||||
value_produced_total_local FLOAT NOT NULL,
|
||||
quantity_used FLOAT NOT NULL,
|
||||
id_unit_quantity INT NOT NULL,
|
||||
CONSTRAINT FK_tmp_Manuf_Purch_Order_Product_Link_id_unit_quantity
|
||||
FOREIGN KEY (id_unit_quantity)
|
||||
REFERENCES Shop_Unit_Measurement(id_unit_measurement),
|
||||
quantity_produced FLOAT NULL,
|
||||
latency_manufacture_days INT NOT NULL,
|
||||
display_order INT NOT NULL,
|
||||
active BIT NOT NULL,
|
||||
name_error VARCHAR(200) NOT NULL
|
||||
);
|
||||
|
||||
CREATE 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,
|
||||
CONSTRAINT FK_tmp_Msg_Error_id_type
|
||||
FOREIGN KEY (id_type)
|
||||
REFERENCES Shop_Msg_Error_Type (id_type),
|
||||
code VARCHAR(50) NOT NULL,
|
||||
msg VARCHAR(4000) NOT NULL
|
||||
);
|
||||
|
||||
|
||||
-- Argument validation
|
||||
# User ID
|
||||
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error) THEN
|
||||
IF ISNULL(a_id_user) OR NOT EXISTS (SELECT * FROM Shop_User WHERE id_user = a_id_user) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid, id_type, code, msg
|
||||
)
|
||||
VALUES
|
||||
(a_guid, v_id_error_type_bad_data, v_code_error_type_bad_data, CONCAT('Invalid User ID: ', IFNULL(a_id_user, 'NULL')))
|
||||
;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
# Order ID
|
||||
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error) THEN
|
||||
IF ISNULL(a_id_order) OR ((a_id_order > 0) AND NOT EXISTS (SELECT * FROM Shop_Manufacturing_Purchase_Order WHERE id_order = a_id_order)) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid, id_type, code, msg
|
||||
)
|
||||
VALUES
|
||||
(a_guid, v_id_error_type_bad_data, v_code_error_type_bad_data, CONCAT('Invalid Manufacturing Purchase Order ID: ', IFNULL(a_id_order, 'NULL')))
|
||||
;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
/*
|
||||
# Supplier ID
|
||||
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error) THEN
|
||||
IF ISNULL(a_id_supplier_ordered) OR NOT EXISTS (SELECT * FROM Shop_Supplier WHERE id_supplier = a_id_supplier_ordered) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid, id_type, code, msg
|
||||
)
|
||||
VALUES
|
||||
(a_guid, v_id_error_type_bad_data, v_code_error_type_bad_data, CONCAT('Invalid supplier ID: ', IFNULL(a_id_supplier_ordered, 'NULL')))
|
||||
;
|
||||
END IF;
|
||||
END IF;
|
||||
*/
|
||||
|
||||
# Currency ID
|
||||
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error) THEN
|
||||
IF ISNULL(a_id_currency_cost) OR NOT EXISTS (SELECT * FROM Shop_Currency WHERE id_currency = a_id_currency_cost) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid, id_type, code, msg
|
||||
)
|
||||
VALUES
|
||||
(a_guid, v_id_error_type_bad_data, v_code_error_type_bad_data, CONCAT('Invalid currency ID: ', IFNULL(a_id_currency, 'NULL')))
|
||||
;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
# Comment
|
||||
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error) THEN
|
||||
IF ISNULL(a_comment) OR TRIM(a_comment) = '' THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid, id_type, code, msg
|
||||
)
|
||||
VALUES
|
||||
(a_guid, v_id_error_type_bad_data, v_code_error_type_bad_data, 'A comment must be provided.')
|
||||
;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
|
||||
-- Get data from Temp table
|
||||
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error) THEN
|
||||
SET v_is_new_manufacturing_purchase_order := CASE WHEN a_id_order <= 0 THEN 1 ELSE 0 END;
|
||||
|
||||
INSERT INTO tmp_Shop_Manufacturing_Purchase_Order_Product_Link (
|
||||
id_link,
|
||||
id_order,
|
||||
id_permutation,
|
||||
cost_total_local,
|
||||
id_currency_cost,
|
||||
quantity_used,
|
||||
id_unit_quantity,
|
||||
quantity_produced,
|
||||
value_produced_total_local,
|
||||
latency_manufacture_days,
|
||||
display_order,
|
||||
active,
|
||||
name_error
|
||||
)
|
||||
/*
|
||||
VALUES
|
||||
(a_id_supplier, a_name_company, a_name_contact, a_department_contact, a_id_address, a_phone_number, a_fax, a_email, a_website, a_id_currency, a_active)
|
||||
*/
|
||||
SELECT
|
||||
MPOPL_T.id_link,
|
||||
MPOPL_T.id_order,
|
||||
MPOPL_T.id_permutation,
|
||||
PP.cost_local * MPOPL_T.quantity_used AS cost_total_local,
|
||||
MPOPL_T.id_currency_cost,
|
||||
MPOPL_T.quantity_used,
|
||||
MPOPL_T.id_unit_quantity,
|
||||
MPOPL_T.quantity_produced,
|
||||
(PP.cost_local + PP.profit_local_min) * MPOPL_T.quantity_produced AS value_produced_total_local,
|
||||
MPOPL_T.latency_manufacture_days,
|
||||
MPOPL_T.display_order,
|
||||
MPOPL_T.active,
|
||||
CONCAT(PP.id_permutation, ' - ', IFNULL(P.name ,'')) AS name_error
|
||||
FROM Shop_Manufacturing_Purchase_Order_Product_Link_Temp MPOPL_T
|
||||
INNER JOIN Shop_Product_Permutation PP ON MPOPL_T.id_permutation = PP.id_permutation
|
||||
INNER JOIN Shop_Product P ON PP.id_product = P.id_product
|
||||
WHERE MPOPL_T.GUID = a_guid
|
||||
-- GROUP BY MPOPL_T.id_order, name_error, MPOPL_T.id_link
|
||||
/*
|
||||
group by
|
||||
MPOPL_T.id_link,
|
||||
MPOPL_T.id_order,
|
||||
MPOPL_T.id_permutation,
|
||||
cost_total_local,
|
||||
MPOPL_T.id_currency_cost,
|
||||
MPOPL_T.quantity_used,
|
||||
MPOPL_T.id_unit_quantity,
|
||||
MPOPL_T.quantity_produced,
|
||||
value_produced_total_local,
|
||||
MPOPL_T.latency_manufacture_days,
|
||||
MPOPL_T.display_order,
|
||||
MPOPL_T.active,
|
||||
name_error
|
||||
*/
|
||||
-- GROUP BY id_link, P.id_product, PP.id_permutation
|
||||
-- GROUP BY name_error, ID_LINK, cost_total_local, value_produced_total_local
|
||||
;
|
||||
DELETE MPOPL_T
|
||||
FROM Shop_Manufacturing_Purchase_Order_Product_Link_Temp MPOPL_T
|
||||
WHERE MPOPL_T.GUID = a_guid
|
||||
;
|
||||
END IF;
|
||||
|
||||
-- Invalid quantity used
|
||||
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error) THEN
|
||||
IF EXISTS (
|
||||
SELECT *
|
||||
FROM tmp_Shop_Manufacturing_Purchase_Order_Product_Link
|
||||
WHERE
|
||||
NOT ISNULL(quantity_used)
|
||||
AND quantity_used < 0
|
||||
) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid, id_type, code, msg
|
||||
)
|
||||
SELECT
|
||||
a_guid,
|
||||
v_id_error_type_bad_data,
|
||||
v_code_error_type_bad_data,
|
||||
CONCAT('Invalid quantity used property for the following permutations: ', GROUP_CONCAT(t_MPOPL.name_error SEPARATOR ', '))
|
||||
FROM tmp_Shop_Manufacturing_Purchase_Order_Product_Link t_MPOPL
|
||||
WHERE t_MPOPL.quantity_used < 0
|
||||
;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
-- Invalid quantity produced
|
||||
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error) THEN
|
||||
IF EXISTS (
|
||||
SELECT *
|
||||
FROM tmp_Shop_Manufacturing_Purchase_Order_Product_Link
|
||||
WHERE
|
||||
NOT ISNULL(quantity_produced)
|
||||
AND quantity_produced < 0
|
||||
) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid, id_type, code, msg
|
||||
)
|
||||
SELECT
|
||||
a_guid,
|
||||
v_id_error_type_bad_data,
|
||||
v_code_error_type_bad_data,
|
||||
CONCAT('Invalid quantity produced property for the following permutations: ', GROUP_CONCAT(t_MPOPL.name_error SEPARATOR ', '))
|
||||
FROM tmp_Shop_Manufacturing_Purchase_Order_Product_Link t_MPOPL
|
||||
WHERE t_MPOPL.quantity_produced < 0
|
||||
;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
-- Duplicates
|
||||
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error) THEN
|
||||
IF EXISTS (SELECT id_permutation, name_error, COUNT(*) FROM tmp_Shop_Manufacturing_Purchase_Order_Product_Link t_MPOPL GROUP BY id_permutation HAVING COUNT(*) > 1) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid, id_type, code, msg
|
||||
)
|
||||
SELECT
|
||||
a_guid,
|
||||
v_id_error_type_bad_data,
|
||||
v_code_error_type_bad_data,
|
||||
CONCAT('Duplicate records: ', GROUP_CONCAT(t_MPOPLC.name_error SEPARATOR ', '))
|
||||
FROM (SELECT id_permutation, name_error, COUNT(*) FROM tmp_Shop_Manufacturing_Purchase_Order_Product_Link t_MPOPL GROUP BY id_permutation HAVING COUNT(*) > 1) t_MPOPLC
|
||||
;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
|
||||
-- Permissions
|
||||
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error) THEN
|
||||
SET v_ids_product := (
|
||||
SELECT GROUP_CONCAT(G.id_product SEPARATOR ',')
|
||||
FROM (
|
||||
SELECT DISTINCT PP.id_product
|
||||
FROM tmp_Shop_Manufacturing_Purchase_Order_Product_Link t_MPO
|
||||
INNER JOIN Shop_Product_Permutation PP ON t_MPO.id_permutation = PP.id_permutation
|
||||
) G
|
||||
);
|
||||
|
||||
CALL p_shop_user_eval(v_guid_permission, a_id_user, 0, v_id_permission_manufacturing_purchase_order, v_id_access_level_edit, v_ids_product);
|
||||
|
||||
/*
|
||||
UPDATE tmp_Shop_Supplier t_S
|
||||
INNER JOIN Shop_User_Eval_Temp TP
|
||||
ON TP.GUID = v_guid_permission
|
||||
SET tP.can_view = TP.can_view,
|
||||
tP.can_edit = TP.can_edit,
|
||||
tP.can_admin = TP.can_admin;
|
||||
*/
|
||||
/*
|
||||
SET v_has_permission := (
|
||||
SELECT can_edit
|
||||
FROM Shop_User_Eval_Temp
|
||||
WHERE
|
||||
GUID = v_guid_permission
|
||||
AND can_edit = 0
|
||||
);
|
||||
|
||||
IF v_has_permission = 0 THEN
|
||||
SET v_id_error_type_no_permission := (SELECT id_type FROM Shop_Msg_Error_Type WHERE code = 'NO_PERMISSION');
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid, id_type, msg
|
||||
)
|
||||
SELECT
|
||||
a_guid,
|
||||
v_id_error_type_no_permission,
|
||||
CONCAT('You do not have ', name, ' permissions.')
|
||||
FROM Shop_Permission
|
||||
WHERE id_permission = v_id_permission_manufacturing_purchase_order
|
||||
;
|
||||
END IF;
|
||||
*/
|
||||
SET v_ids_product_no_permission := (
|
||||
SELECT GROUP_CONCAT(PT.id_product SEPARATOR ',')
|
||||
FROM Shop_User_Eval_Temp PT
|
||||
WHERE
|
||||
PT.can_edit = 0
|
||||
AND NOT ISNULL(PT.id_product)
|
||||
);
|
||||
IF NOT ISNULL(v_ids_product_no_permission) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid, id_type, code, msg
|
||||
)
|
||||
VALUES (
|
||||
a_guid,
|
||||
v_id_error_type_no_permission,
|
||||
v_code_error_type_no_permission,
|
||||
CONCAT('You do not have permission to edit the following product IDs: ', v_ids_product_no_permission)
|
||||
)
|
||||
;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
-- Transaction
|
||||
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error) THEN
|
||||
START TRANSACTION;
|
||||
INSERT INTO Shop_Sales_And_Purchasing_Change_Set (
|
||||
comment,
|
||||
updated_last_by,
|
||||
updated_last_on
|
||||
)
|
||||
VALUES (
|
||||
CONCAT(
|
||||
'Save ',
|
||||
CASE WHEN v_is_new_manufacturing_purchase_order = 1 THEN 'new ' ELSE '' END,
|
||||
'Manufacturing Purchase Order - ',
|
||||
a_comment
|
||||
),
|
||||
a_id_user,
|
||||
CURRENT_TIME()
|
||||
);
|
||||
|
||||
SET v_id_change_set := (SELECT id_change_set FROM Shop_Sales_And_Purchasing_Change_Set ORDER BY id_change_set DESC LIMIT 1);
|
||||
|
||||
IF (v_is_new_manufacturing_purchase_order = 1) THEN
|
||||
INSERT INTO Shop_Manufacturing_Purchase_Order (
|
||||
-- id_supplier_ordered,
|
||||
cost_total_local,
|
||||
id_currency_cost,
|
||||
value_produced_total_local,
|
||||
created_by,
|
||||
id_change_set,
|
||||
active
|
||||
)
|
||||
SELECT
|
||||
-- a_id_supplier_ordered,
|
||||
SUM(t_MPOPL.cost_total_local),
|
||||
a_id_currency_cost,
|
||||
SUM(t_MPOPL.value_produced_total_local),
|
||||
a_id_user,
|
||||
v_id_change_set,
|
||||
a_active
|
||||
FROM tmp_Shop_Manufacturing_Purchase_Order_Product_Link t_MPOPL
|
||||
;
|
||||
-- SET v_id_order_new
|
||||
SET a_id_order := (SELECT id_order FROM Shop_Manufacturing_Purchase_Order ORDER BY id_order DESC LIMIT 1);
|
||||
|
||||
INSERT INTO Shop_Manufacturing_Purchase_Order_Product_Link (
|
||||
id_order,
|
||||
id_permutation,
|
||||
cost_total_local,
|
||||
value_produced_total_local,
|
||||
id_currency_cost,
|
||||
quantity_used,
|
||||
id_unit_quantity,
|
||||
quantity_produced,
|
||||
latency_manufacture_days,
|
||||
display_order,
|
||||
active,
|
||||
created_by,
|
||||
id_change_set
|
||||
)
|
||||
SELECT
|
||||
a_id_order, -- v_id_order_new,
|
||||
id_permutation,
|
||||
cost_total_local,
|
||||
value_produced_total_local,
|
||||
id_currency_cost,
|
||||
quantity_used,
|
||||
id_unit_quantity,
|
||||
quantity_produced,
|
||||
latency_manufacture_days,
|
||||
display_order,
|
||||
active,
|
||||
a_id_user,
|
||||
v_id_change_set
|
||||
FROM tmp_Shop_Manufacturing_Purchase_Order_Product_Link t_MPOPL
|
||||
;
|
||||
ELSE
|
||||
UPDATE Shop_Manufacturing_Purchase_Order MPO
|
||||
INNER JOIN tmp_Shop_Manufacturing_Purchase_Order_Product_Link t_MPOPL ON MPO.id_order = t_MPOPL.id_order
|
||||
SET
|
||||
-- MPO.id_supplier_ordered = a_id_supplier_ordered,
|
||||
MPO.cost_total_local = SUM(t_MPOPL.cost_total_local),
|
||||
MPO.value_produced_total_local = SUM(t_MPOPL.value_produced_total_local),
|
||||
MPO.id_currency = a_id_currency_cost,
|
||||
MPO.id_change_set = v_id_change_set,
|
||||
MPO.active = a_active
|
||||
WHERE MPO.id_order = a_id_order
|
||||
;
|
||||
IF EXISTS (SELECT * FROM tmp_Shop_Manufacturing_Purchase_Order_Product_Link t_MPOPL INNER JOIN Shop_Manufacturing_Purchase_Order_Product_Link MPOPL ON t_MPOPL.id_link = MPOPL.id_link) THEN
|
||||
UPDATE Shop_Manufacturing_Purchase_Order_Product_Link MPOPL
|
||||
INNER JOIN tmp_Shop_Manufacturing_Purchase_Order_Product_Link t_MPOPL
|
||||
ON MPOPL.id_link = t_MPOPL.id_link
|
||||
SET
|
||||
MPOPL.id_order = t_MPOPL.id_order,
|
||||
MPOPL.id_permutation = t_MPOPL.id_permutation,
|
||||
MPOPL.cost_total_local = t_MPOPL.cost_total_local,
|
||||
MPOPL.value_produced_total_local = t_MPOPL.value_produced_total_local,
|
||||
MPOPL.id_currency_cost = t_MPOPL.id_currency_cost,
|
||||
MPOPL.quantity_used = t_MPOPL.quantity_used,
|
||||
MPOPL.id_unit_quantity = t_MPOPL.id_unit_quantity,
|
||||
MPOPL.quantity_produced = t_MPOPL.quantity_produced,
|
||||
MPOPL.latency_manufacture_days = t_MPOPL.latency_manufacture_days,
|
||||
MPOPL.display_order = t_MPOPL.display_order,
|
||||
MPOPL.active = t_MPOPL.active,
|
||||
MPOPL.id_change_set = v_id_change_set
|
||||
;
|
||||
ELSE
|
||||
INSERT INTO Shop_Manufacturing_Purchase_Order_Product_Link (
|
||||
id_order,
|
||||
id_permutation,
|
||||
cost_total_local,
|
||||
value_produced_total_local,
|
||||
id_currency_cost,
|
||||
quantity_used,
|
||||
id_unit_quantity,
|
||||
quantity_produced,
|
||||
latency_manufacture_days,
|
||||
display_order,
|
||||
active,
|
||||
created_by,
|
||||
id_change_set
|
||||
)
|
||||
SELECT
|
||||
id_order,
|
||||
id_permutation,
|
||||
cost_total_local,
|
||||
value_produced_total_local,
|
||||
id_currency_cost,
|
||||
quantity_used,
|
||||
id_unit_quantity,
|
||||
quantity_produced,
|
||||
latency_manufacture_days,
|
||||
display_order,
|
||||
active,
|
||||
a_id_user,
|
||||
v_id_change_set
|
||||
FROM tmp_Shop_Manufacturing_Purchase_Order_Product_Link t_MPOPL
|
||||
WHERE t_MPOPL.id_link < 0
|
||||
;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
IF EXISTS (SELECT * FROM tmp_Msg_Error) THEN
|
||||
ROLLBACK;
|
||||
ELSE
|
||||
COMMIT;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
-- Returns
|
||||
# SET v_now = NOW();
|
||||
|
||||
# Manufacturing Purchase Orders
|
||||
SELECT *
|
||||
FROM Shop_Manufacturing_Purchase_Order
|
||||
WHERE
|
||||
id_order = a_id_order
|
||||
-- GUID = a_guid
|
||||
;
|
||||
|
||||
# Manufacturing Purchase Order Product Links
|
||||
SELECT *
|
||||
FROM Shop_Manufacturing_Purchase_Order_Product_Link
|
||||
WHERE
|
||||
id_order = a_id_order
|
||||
-- GUID = a_guid
|
||||
;
|
||||
|
||||
# Errors
|
||||
SELECT *
|
||||
FROM tmp_Msg_Error
|
||||
;
|
||||
|
||||
# DROP TABLE tmp_Shop_Manufacturing_Purchase_Order;
|
||||
DROP TABLE tmp_Shop_Manufacturing_Purchase_Order_Product_Link;
|
||||
DROP TABLE tmp_Msg_Error;
|
||||
END //
|
||||
DELIMITER ;;
|
||||
|
||||
|
||||
/*
|
||||
|
||||
DELETE FROM Shop_Manufacturing_Purchase_Order_Product_Link_Audit;
|
||||
DELETE FROM Shop_Manufacturing_Purchase_Order_Product_Link;
|
||||
DELETE FROM Shop_Manufacturing_Purchase_Order_Product_Link_Temp;
|
||||
DELETE FROM Shop_Manufacturing_Purchase_Order_Audit;
|
||||
DELETE FROM Shop_Manufacturing_Purchase_Order;
|
||||
|
||||
INSERT INTO Shop_Manufacturing_Purchase_Order_Product_Link_Temp (
|
||||
guid,
|
||||
id_link,
|
||||
id_order,
|
||||
id_permutation,
|
||||
cost_total_local,
|
||||
id_currency_cost,
|
||||
quantity_used,
|
||||
id_unit_quantity,
|
||||
quantity_produced,
|
||||
latency_manufacture_days,
|
||||
display_order,
|
||||
active
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
'NIPS', # guid
|
||||
-1, # id_link,
|
||||
-1, # id_order,
|
||||
1, # id_permutation,
|
||||
100, # cost_total_local,
|
||||
1, # id_currency_cost,
|
||||
1, # quantity_used,
|
||||
1, # id_unit_quantity,
|
||||
1, # quantity_produced,
|
||||
14, # latency_manufacture_days ,
|
||||
1, # display_order
|
||||
1 # active
|
||||
)
|
||||
;
|
||||
|
||||
SELECT * FROM Shop_Manufacturing_Purchase_Order_Product_Link_Temp;
|
||||
|
||||
CALL p_shop_save_manufacturing_purchase_order (
|
||||
'NIPS', # a_guid
|
||||
'auth0|6582b95c895d09a70ba10fef', # a_id_user
|
||||
-1, # a_id_order
|
||||
1, # a_id_currency_cost
|
||||
1, # a_active
|
||||
'Initial data' # a_comment
|
||||
);
|
||||
|
||||
SELECT * FROM Shop_Manufacturing_Purchase_Order_Product_Link_Temp;
|
||||
|
||||
DELETE FROM Shop_Manufacturing_Purchase_Order_Product_Link_Audit;
|
||||
DELETE FROM Shop_Manufacturing_Purchase_Order_Product_Link;
|
||||
DELETE FROM Shop_Manufacturing_Purchase_Order_Product_Link_Temp;
|
||||
DELETE FROM Shop_Manufacturing_Purchase_Order_Audit;
|
||||
DELETE FROM Shop_Manufacturing_Purchase_Order;
|
||||
|
||||
|
||||
*/
|
||||
|
||||
561
static/MySQL/7206_p_shop_save_product_permutation.sql
Normal file
561
static/MySQL/7206_p_shop_save_product_permutation.sql
Normal file
@@ -0,0 +1,561 @@
|
||||
|
||||
|
||||
-- Clear previous proc
|
||||
DROP PROCEDURE IF EXISTS p_shop_save_permutation;
|
||||
DROP PROCEDURE IF EXISTS p_shop_save_product_permutation;
|
||||
|
||||
DELIMITER //
|
||||
CREATE PROCEDURE p_shop_save_product_permutation (
|
||||
IN a_id_user INT,
|
||||
IN a_comment VARCHAR(500),
|
||||
IN a_guid BINARY(36)
|
||||
)
|
||||
BEGIN
|
||||
|
||||
DECLARE v_code_type_error_bad_data VARCHAR(100);
|
||||
DECLARE v_id_type_error_bad_data INT;
|
||||
DECLARE v_id_permission_product INT;
|
||||
DECLARE v_ids_product_permission LONGTEXT;
|
||||
DECLARE v_id_change_set INT;
|
||||
DECLARE v_id_access_level_edit INT;
|
||||
DECLARE v_now TIMESTAMP;
|
||||
|
||||
DECLARE exit handler for SQLEXCEPTION
|
||||
BEGIN
|
||||
-- Get diagnostic information
|
||||
GET DIAGNOSTICS CONDITION 1
|
||||
@sqlstate = RETURNED_SQLSTATE
|
||||
, @errno = MYSQL_ERRNO
|
||||
, @text = MESSAGE_TEXT
|
||||
;
|
||||
|
||||
-- Rollback the transaction
|
||||
ROLLBACK;
|
||||
|
||||
-- Select the error information
|
||||
-- SELECT 'Error' AS status, @errno AS error_code, @sqlstate AS sql_state, @text AS message;
|
||||
|
||||
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 NULL
|
||||
, code VARCHAR(50) NOT NULL
|
||||
, msg VARCHAR(4000) NOT NULL
|
||||
);
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid
|
||||
, id_type
|
||||
, code
|
||||
, msg
|
||||
)
|
||||
SELECT
|
||||
a_guid
|
||||
, NULL
|
||||
, @errno
|
||||
, @text
|
||||
;
|
||||
SELECT *
|
||||
FROM tmp_Msg_Error;
|
||||
DROP TABLE IF EXISTS tmp_Msg_Error;
|
||||
END;
|
||||
|
||||
SET v_code_type_error_bad_data := 'BAD_DATA';
|
||||
SET v_id_type_error_bad_data := (SELECT id_type FROM Shop_Msg_Error_Type WHERE code = v_code_type_error_bad_data LIMIT 1);
|
||||
SET v_id_access_level_edit := (SELECT id_access_level FROM Shop_Access_Level WHERE code = 'EDIT' LIMIT 1);
|
||||
|
||||
SET a_guid := IFNULL(a_guid, UUID());
|
||||
|
||||
DROP TABLE IF EXISTS tmp_Permutation;
|
||||
|
||||
CREATE TEMPORARY TABLE tmp_Permutation (
|
||||
id_permutation INT NOT NULL
|
||||
, id_product INT NOT NULL
|
||||
, description VARCHAR(4000) NOT NULL
|
||||
, cost_local FLOAT NOT NULL
|
||||
, id_currency_cost INT NOT NULL
|
||||
, profit_local_min FLOAT NOT NULL
|
||||
, latency_manufacture_days INT NOT NULL
|
||||
, id_unit_measurement_quantity INT NOT NULL
|
||||
, count_unit_measurement_per_quantity_step FLOAT NOT NULL
|
||||
, quantity_min FLOAT NOT NULL
|
||||
, quantity_max FLOAT NOT NULL
|
||||
, quantity_stock FLOAT NOT NULL
|
||||
, is_subscription BIT NOT NULL
|
||||
, id_unit_measurement_interval_recurrence INT
|
||||
, count_interval_recurrence INT
|
||||
, id_stripe_product VARCHAR(100) NULL
|
||||
, does_expire_faster_once_unsealed BIT NOT NULL
|
||||
, id_unit_measurement_interval_expiration_unsealed INT
|
||||
, count_interval_expiration_unsealed INT
|
||||
, active BIT NOT NULL DEFAULT 1
|
||||
, can_view BIT NULL
|
||||
, can_edit BIT NULL
|
||||
, can_admin BIT NULL
|
||||
, name_error VARCHAR(255) NOT NULL
|
||||
, is_new BIT 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 NULL
|
||||
, code VARCHAR(50) NOT NULL
|
||||
, msg VARCHAR(4000) NOT NULL
|
||||
);
|
||||
|
||||
|
||||
-- Get data from Temp table
|
||||
INSERT INTO tmp_Permutation (
|
||||
id_permutation
|
||||
, id_product
|
||||
, description
|
||||
, cost_local
|
||||
, id_currency_cost
|
||||
, profit_local_min
|
||||
, latency_manufacture_days
|
||||
, id_unit_measurement_quantity
|
||||
, count_unit_measurement_per_quantity_step
|
||||
, quantity_min
|
||||
, quantity_max
|
||||
, quantity_stock
|
||||
, is_subscription
|
||||
, id_unit_measurement_interval_recurrence
|
||||
, count_interval_recurrence
|
||||
, id_stripe_product
|
||||
, does_expire_faster_once_unsealed
|
||||
, id_unit_measurement_interval_expiration_unsealed
|
||||
, count_interval_expiration_unsealed
|
||||
, active
|
||||
, name_error
|
||||
, is_new
|
||||
)
|
||||
SELECT
|
||||
PP_T.id_permutation
|
||||
, IFNULL(PP_T.id_product, PP.id_product) AS id_product
|
||||
, IFNULL(PP_T.description, PP.description) AS description
|
||||
, IFNULL(PP_T.cost_local, PP.cost_local) AS cost_local
|
||||
, IFNULL(PP_T.id_currency_cost, PP.id_currency_cost) AS a_id_currency_cost
|
||||
, IFNULL(PP_T.profit_local_min, PP.profit_local_min) AS profit_local_min
|
||||
, IFNULL(PP_T.latency_manufacture_days, PP.latency_manufacture_days) AS latency_manufacture_days
|
||||
, IFNULL(PP_T.id_unit_measurement_quantity, PP.id_unit_measurement_quantity) AS id_unit_measurement_quantity
|
||||
, IFNULL(PP_T.count_unit_measurement_per_quantity_step, PP.count_unit_measurement_per_quantity_step) AS count_unit_measurement_per_quantity_step
|
||||
, IFNULL(PP_T.quantity_min, PP.quantity_min) AS quantity_min
|
||||
, IFNULL(PP_T.quantity_max, PP.quantity_max) AS quantity_max
|
||||
, IFNULL(PP_T.quantity_stock, PP.quantity_stock) AS quantity_stock
|
||||
, IFNULL(PP_T.is_subscription, PP.is_subscription) AS is_subscription
|
||||
, IFNULL(PP_T.id_unit_measurement_interval_recurrence, PP.id_unit_measurement_interval_recurrence) AS id_unit_measurement_interval_recurrence
|
||||
, IFNULL(PP_T.count_interval_recurrence, PP.count_interval_recurrence) AS count_interval_recurrence
|
||||
, IFNULL(PP_T.id_stripe_product, PP.id_stripe_product) AS id_stripe_product
|
||||
, IFNULL(PP_T.does_expire_faster_once_unsealed, PP.does_expire_faster_once_unsealed) AS does_expire_faster_once_unsealed
|
||||
, IFNULL(PP_T.id_unit_measurement_interval_expiration_unsealed, PP.id_unit_measurement_interval_expiration_unsealed) AS id_unit_measurement_interval_expiration_unsealed
|
||||
, IFNULL(PP_T.count_interval_expiration_unsealed, PP.count_interval_expiration_unsealed) AS count_interval_expiration_unsealed
|
||||
, IFNULL(PP_T.active, PP.active) AS active
|
||||
, fn_shop_get_product_permutation_name(PP_T.id_permutation)
|
||||
, CASE WHEN IFNULL(PP_T.id_permutation, 0) < 1 THEN 1 ELSE 0 END AS is_new
|
||||
FROM Shop_Product_Permutation_Temp PP_T
|
||||
LEFT JOIN Shop_Product_Permutation PP ON PP_T.id_permutation = PP.id_permutation
|
||||
WHERE PP_T.guid = a_guid
|
||||
;
|
||||
|
||||
-- Validation
|
||||
-- Missing mandatory fields
|
||||
-- id_product
|
||||
IF EXISTS (SELECT * FROM tmp_Permutation t_P WHERE ISNULL(t_P.id_product) LIMIT 1) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid
|
||||
, id_type
|
||||
, id_product
|
||||
, msg
|
||||
)
|
||||
SELECT
|
||||
a_guid AS GUID
|
||||
, v_id_type_error_bad_data
|
||||
, v_code_type_error_bad_data
|
||||
, CONCAT('The following product permutation(s) do not have a product: ', GROUP_CONCAT(IFNULL(t_P.name_error, 'NULL') SEPARATOR ', ')) AS msg
|
||||
FROM tmp_Permutation t_P
|
||||
WHERE ISNULL(t_P.id_product)
|
||||
;
|
||||
END IF;
|
||||
-- cost_local
|
||||
IF EXISTS (SELECT * FROM tmp_Permutation t_P WHERE ISNULL(t_P.cost_local) LIMIT 1) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid
|
||||
, id_type
|
||||
, cost_local
|
||||
, msg
|
||||
)
|
||||
SELECT
|
||||
a_guid AS GUID
|
||||
, v_id_type_error_bad_data
|
||||
, v_code_type_error_bad_data
|
||||
, CONCAT('The following product permutation(s) do not have a local cost: ', GROUP_CONCAT(IFNULL(t_P.name_error, 'NULL') SEPARATOR ', ')) AS msg
|
||||
FROM tmp_Permutation t_P
|
||||
WHERE ISNULL(t_P.cost_local)
|
||||
;
|
||||
END IF;
|
||||
-- profit_local_min
|
||||
IF EXISTS (SELECT * FROM tmp_Permutation t_P WHERE ISNULL(t_P.profit_local_min) LIMIT 1) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid
|
||||
, id_type
|
||||
, profit_local_min
|
||||
, msg
|
||||
)
|
||||
SELECT
|
||||
a_guid AS GUID
|
||||
, v_id_type_error_bad_data
|
||||
, v_code_type_error_bad_data
|
||||
, CONCAT('The following product permutation(s) do not have a local minimum profit: ', GROUP_CONCAT(IFNULL(t_P.name_error, 'NULL') SEPARATOR ', ')) AS msg
|
||||
FROM tmp_Permutation t_P
|
||||
WHERE ISNULL(t_P.profit_local_min)
|
||||
;
|
||||
END IF;
|
||||
-- latency_manufacture_days
|
||||
IF EXISTS (SELECT * FROM tmp_Permutation t_P WHERE ISNULL(t_P.latency_manufacture_days) LIMIT 1) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid
|
||||
, id_type
|
||||
, latency_manufacture_days
|
||||
, msg
|
||||
)
|
||||
SELECT
|
||||
a_guid AS GUID
|
||||
, v_id_type_error_bad_data
|
||||
, v_code_type_error_bad_data
|
||||
, CONCAT('The following product permutation(s) do not have a manufacturing latency: ', GROUP_CONCAT(IFNULL(t_P.name_error, 'NULL') SEPARATOR ', ')) AS msg
|
||||
FROM tmp_Permutation t_P
|
||||
WHERE ISNULL(t_P.latency_manufacture_days)
|
||||
;
|
||||
END IF;
|
||||
-- id_unit_measurement_quantity
|
||||
IF EXISTS (SELECT * FROM tmp_Permutation t_P WHERE ISNULL(t_P.id_unit_measurement_quantity) LIMIT 1) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid
|
||||
, id_type
|
||||
, id_unit_measurement_quantity
|
||||
, msg
|
||||
)
|
||||
SELECT
|
||||
a_guid AS GUID
|
||||
, v_id_type_error_bad_data
|
||||
, v_code_type_error_bad_data
|
||||
, CONCAT('The following product permutation(s) do not have a unit measurement for stock quantities: ', GROUP_CONCAT(IFNULL(t_P.name_error, 'NULL') SEPARATOR ', ')) AS msg
|
||||
FROM tmp_Permutation t_P
|
||||
WHERE ISNULL(t_P.id_unit_measurement_quantity)
|
||||
;
|
||||
END IF;
|
||||
-- count_unit_measurement_per_quantity_step
|
||||
IF EXISTS (SELECT * FROM tmp_Permutation t_P WHERE ISNULL(t_P.count_unit_measurement_per_quantity_step) LIMIT 1) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid
|
||||
, id_type
|
||||
, count_unit_measurement_per_quantity_step
|
||||
, msg
|
||||
)
|
||||
SELECT
|
||||
a_guid AS GUID
|
||||
, v_id_type_error_bad_data
|
||||
, v_code_type_error_bad_data
|
||||
, CONCAT('The following product permutation(s) do not have a count unit measurement per quantity step: ', GROUP_CONCAT(IFNULL(t_P.name_error, 'NULL') SEPARATOR ', ')) AS msg
|
||||
FROM tmp_Permutation t_P
|
||||
WHERE ISNULL(t_P.count_unit_measurement_per_quantity_step)
|
||||
;
|
||||
END IF;
|
||||
-- quantity_min
|
||||
IF EXISTS (SELECT * FROM tmp_Permutation t_P WHERE ISNULL(t_P.quantity_min) LIMIT 1) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid
|
||||
, id_type
|
||||
, quantity_min
|
||||
, msg
|
||||
)
|
||||
SELECT
|
||||
a_guid AS GUID
|
||||
, v_id_type_error_bad_data
|
||||
, v_code_type_error_bad_data
|
||||
, CONCAT('The following product permutation(s) do not have a minimum quantity: ', GROUP_CONCAT(IFNULL(t_P.name_error, 'NULL') SEPARATOR ', ')) AS msg
|
||||
FROM tmp_Permutation t_P
|
||||
WHERE ISNULL(t_P.quantity_min)
|
||||
;
|
||||
END IF;
|
||||
-- quantity_max
|
||||
IF EXISTS (SELECT * FROM tmp_Permutation t_P WHERE ISNULL(t_P.quantity_max) LIMIT 1) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid
|
||||
, id_type
|
||||
, quantity_max
|
||||
, msg
|
||||
)
|
||||
SELECT
|
||||
a_guid AS GUID
|
||||
, v_id_type_error_bad_data
|
||||
, v_code_type_error_bad_data
|
||||
, CONCAT('The following product permutation(s) do not have a maximum quantity: ', GROUP_CONCAT(IFNULL(t_P.name_error, 'NULL') SEPARATOR ', ')) AS msg
|
||||
FROM tmp_Permutation t_P
|
||||
WHERE ISNULL(t_P.quantity_max)
|
||||
;
|
||||
END IF;
|
||||
-- is_subscription
|
||||
IF EXISTS (SELECT * FROM tmp_Permutation t_P WHERE ISNULL(t_P.is_subscription) LIMIT 1) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid
|
||||
, id_type
|
||||
, is_subscription
|
||||
, msg
|
||||
)
|
||||
SELECT
|
||||
a_guid AS GUID
|
||||
, v_id_type_error_bad_data
|
||||
, v_code_type_error_bad_data
|
||||
, CONCAT('The following product permutation(s) do not have an is subscription?: ', GROUP_CONCAT(IFNULL(t_P.name_error, 'NULL') SEPARATOR ', ')) AS msg
|
||||
FROM tmp_Permutation t_P
|
||||
WHERE ISNULL(t_P.is_subscription)
|
||||
;
|
||||
END IF;
|
||||
-- does_expire_faster_once_unsealed
|
||||
IF EXISTS (SELECT * FROM tmp_Permutation t_P WHERE ISNULL(t_P.does_expire_faster_once_unsealed) LIMIT 1) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid
|
||||
, id_type
|
||||
, does_expire_faster_once_unsealed
|
||||
, msg
|
||||
)
|
||||
SELECT
|
||||
a_guid AS GUID
|
||||
, v_id_type_error_bad_data
|
||||
, v_code_type_error_bad_data
|
||||
, CONCAT('The following product permutation(s) do not have a does expire faster once unsealed: ', GROUP_CONCAT(IFNULL(t_P.name_error, 'NULL') SEPARATOR ', ')) AS msg
|
||||
FROM tmp_Permutation t_P
|
||||
WHERE ISNULL(t_P.does_expire_faster_once_unsealed)
|
||||
;
|
||||
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_Permutation t_P
|
||||
ON P.id_product = t_P.id_product
|
||||
-- AND t_P.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_user_eval(a_guid, a_id_user, FALSE, v_id_permission_product, v_id_access_level_edit, v_ids_product_permission);
|
||||
|
||||
UPDATE tmp_Permutation t_P
|
||||
INNER JOIN Shop_Product P ON t_P.id_product = P.id_product
|
||||
INNER JOIN Shop_User_Eval_Temp UE_T
|
||||
ON 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 p_clear_shop_user_eval_temp(a_guid);
|
||||
|
||||
IF EXISTS (SELECT * FROM tmp_Permutation t_P WHERE ISNULL(t_P.can_edit) LIMIT 1) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid
|
||||
, id_type
|
||||
, code
|
||||
, msg
|
||||
)
|
||||
SELECT
|
||||
a_guid AS GUID
|
||||
, v_id_type_error_bad_data
|
||||
, v_code_type_error_bad_data
|
||||
, CONCAT('The following product permutation(s) do not have product edit permission: ', GROUP_CONCAT(IFNULL(t_P.name_error, 'NULL') SEPARATOR ', ')) AS msg
|
||||
FROM tmp_Permutation t_P
|
||||
WHERE ISNULL(t_P.can_edit)
|
||||
;
|
||||
END IF;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
SET v_now := CURRENT_TIMESTAMP();
|
||||
|
||||
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error LIMIT 1) THEN
|
||||
START TRANSACTION;
|
||||
|
||||
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_Permutation PP
|
||||
INNER JOIN tmp_Permutation t_P ON PP.id_permutation = t_P.id_permutation
|
||||
SET
|
||||
PP.id_product = t_P.id_product
|
||||
, PP.description = t_P.description
|
||||
, PP.cost_local = t_P.cost_local
|
||||
, PP.id_currency_cost = t_P.id_currency_cost
|
||||
, PP.profit_local_min = t_P.profit_local_min
|
||||
, PP.latency_manufacture_days = t_P.latency_manufacture_days
|
||||
, PP.id_unit_measurement_quantity = t_P.id_unit_measurement_quantity
|
||||
, PP.count_unit_measurement_per_quantity_step = t_P.count_unit_measurement_per_quantity_step
|
||||
, PP.quantity_min = t_P.quantity_min
|
||||
, PP.quantity_max = t_P.quantity_max
|
||||
, PP.quantity_stock = t_P.quantity_stock
|
||||
, PP.is_subscription = t_P.is_subscription
|
||||
, PP.id_unit_measurement_interval_recurrence = t_P.id_unit_measurement_interval_recurrence
|
||||
, PP.count_interval_recurrence = t_P.count_interval_recurrence
|
||||
, PP.id_stripe_product = t_P.id_stripe_product
|
||||
, PP.does_expire_faster_once_unsealed = t_P.does_expire_faster_once_unsealed
|
||||
, PP.id_unit_measurement_interval_expiration_unsealed = t_P.id_unit_measurement_interval_expiration_unsealed
|
||||
, PP.count_interval_expiration_unsealed = t_P.count_interval_expiration_unsealed
|
||||
, PP.active = t_P.active
|
||||
, PP.id_change_set = v_id_change_set
|
||||
;
|
||||
END IF;
|
||||
|
||||
INSERT INTO Shop_Product_Permutation (
|
||||
id_product
|
||||
, description
|
||||
, cost_local
|
||||
, id_currency_cost
|
||||
, profit_local_min
|
||||
, latency_manufacture_days
|
||||
, id_unit_measurement_quantity
|
||||
, count_unit_measurement_per_quantity_step
|
||||
, quantity_min
|
||||
, quantity_max
|
||||
, quantity_stock
|
||||
, is_subscription
|
||||
, id_unit_measurement_interval_recurrence
|
||||
, count_interval_recurrence
|
||||
, id_stripe_product
|
||||
, does_expire_faster_once_unsealed
|
||||
, id_unit_measurement_interval_expiration_unsealed
|
||||
, count_interval_expiration_unsealed
|
||||
, active
|
||||
, created_by
|
||||
, created_on
|
||||
)
|
||||
SELECT
|
||||
t_P.id_product AS id_product
|
||||
, t_P.description AS description
|
||||
, t_P.cost_local AS cost_local
|
||||
, t_P.id_currency_cost AS id_currency_cost
|
||||
, t_P.profit_local_min AS profit_local_min
|
||||
, t_P.latency_manufacture_days AS latency_manufacture_days
|
||||
, t_P.id_unit_measurement_quantity AS id_unit_measurement_quantity
|
||||
, t_P.count_unit_measurement_per_quantity_step AS count_unit_measurement_per_quantity_step
|
||||
, t_P.quantity_min AS quantity_min
|
||||
, t_P.quantity_max AS quantity_max
|
||||
, t_P.quantity_stock AS quantity_stock
|
||||
, t_P.is_subscription AS is_subscription
|
||||
, t_P.id_unit_measurement_interval_recurrence AS id_unit_measurement_interval_recurrence
|
||||
, t_P.count_interval_recurrence AS count_interval_recurrence
|
||||
, t_P.id_stripe_product AS id_stripe_product
|
||||
, t_P.does_expire_faster_once_unsealed AS does_expire_faster_once_unsealed
|
||||
, t_P.id_unit_measurement_interval_expiration_unsealed AS id_unit_measurement_interval_expiration_unsealed
|
||||
, t_P.count_interval_expiration_unsealed AS count_interval_expiration_unsealed
|
||||
, t_P.active AS active
|
||||
, a_id_user AS created_by
|
||||
, v_now AS created_on
|
||||
FROM tmp_Permutation t_P
|
||||
WHERE
|
||||
is_new = 1
|
||||
AND active = 1
|
||||
;
|
||||
|
||||
DELETE FROM Shop_Product_Permutation_Temp
|
||||
WHERE GUID = a_guid;
|
||||
|
||||
COMMIT;
|
||||
END IF;
|
||||
|
||||
SELECT * FROM tmp_Msg_Error;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Permutation;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Msg_Error;
|
||||
END //
|
||||
DELIMITER ;;
|
||||
|
||||
|
||||
/*
|
||||
|
||||
DELETE FROM Shop_Product_Permutation_Temp
|
||||
WHERE id_permutation = 1
|
||||
;
|
||||
|
||||
INSERT INTO Shop_Product_Permutation_Temp (
|
||||
id_permutation,
|
||||
id_product,
|
||||
description,
|
||||
cost_local,
|
||||
id_currency_cost,
|
||||
profit_local_min,
|
||||
latency_manufacture_days,
|
||||
id_unit_measurement_quantity,
|
||||
count_unit_measurement_per_quantity_step,
|
||||
quantity_min,
|
||||
quantity_max,
|
||||
quantity_stock,
|
||||
is_subscription,
|
||||
id_unit_measurement_interval_recurrence,
|
||||
count_interval_recurrence,
|
||||
id_stripe_product,
|
||||
does_expire_faster_once_unsealed,
|
||||
id_unit_measurement_interval_expiration_unsealed,
|
||||
count_interval_expiration_unsealed,
|
||||
active,
|
||||
guid
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
1 -- id_permutation,
|
||||
, 1 -- id_product,
|
||||
, 'Good Reddy Teddy' -- description,
|
||||
, 5.0 -- cost_local,
|
||||
, 1 -- id_currency_cost,
|
||||
, 3.0 -- profit_local_min,
|
||||
, 14 -- latency_manufacture_days,
|
||||
, 1 -- id_unit_measurement_quantity,
|
||||
, 1.0 -- count_unit_measurement_quantity,
|
||||
, 3.0 -- quantity_min,
|
||||
, 99.0 -- quantity_max,
|
||||
, 1.0 -- quantity_stock,
|
||||
, False -- is_subscription,
|
||||
, null -- id_unit_measurement_interval_recurrence,
|
||||
, null -- count_interval_recurrence,
|
||||
, null -- id_stripe_product,
|
||||
, False -- does_expire_faster_once_unsealed,
|
||||
, null -- id_unit_measurement_interval_expiration_unsealed,
|
||||
, null -- count_interval_expiration_unsealed,
|
||||
, True -- active,
|
||||
, 'NIPS' -- guid
|
||||
)
|
||||
;
|
||||
|
||||
select 'Shop_Product_Permutation_Temp before call';
|
||||
SELECT * FROM Shop_Product_Permutation_Temp;
|
||||
|
||||
SELECT 'Shop_Product_Permutation before call' AS result_name;
|
||||
select * FROM Shop_Product_Permutation;
|
||||
|
||||
CALL p_shop_save_product_permutation (
|
||||
1, -- 'auth0|6582b95c895d09a70ba10fef', # a_id_user
|
||||
'Initial data', # a_comment
|
||||
'NIPS' # a_guid
|
||||
);
|
||||
|
||||
SELECT 'Shop_Product_Permutation_Temp after call' AS result_name;
|
||||
select * FROM Shop_Product_Permutation_Temp;
|
||||
|
||||
SELECT 'Shop_Product_Permutation after call' AS result_name;
|
||||
select * FROM Shop_Product_Permutation;
|
||||
|
||||
|
||||
DELETE FROM Shop_Product_Permutation_Temp
|
||||
WHERE id_permutation = 1;
|
||||
|
||||
|
||||
*/
|
||||
|
||||
@@ -1,23 +1,6 @@
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
CALL p_shop_get_many_product_variation (
|
||||
'', # a_id_user
|
||||
1, # a_get_all_supplier
|
||||
0, # a_get_inactive_variation
|
||||
0, # a_get_first_variation_only
|
||||
'', # a_ids_variation
|
||||
);
|
||||
|
||||
*/
|
||||
|
||||
|
||||
-- Clear previous proc
|
||||
DROP PROCEDURE IF EXISTS p_shop_get_many_product_variation;
|
||||
|
||||
|
||||
DELIMITER //
|
||||
CREATE PROCEDURE p_shop_get_many_product_variation (
|
||||
IN a_id_user INT,
|
||||
@@ -236,32 +219,33 @@ BEGIN
|
||||
END IF;
|
||||
|
||||
-- Returns
|
||||
/*
|
||||
# Variation Types
|
||||
SELECT
|
||||
t_VT.id_type
|
||||
, VT.code
|
||||
, VT.name
|
||||
, VT.name_plural
|
||||
, VT.display_order
|
||||
, VT.active
|
||||
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
|
||||
, t_V.id_type
|
||||
, V.code AS code_variation
|
||||
, V.name AS name_variation
|
||||
, V.active AS active_variation
|
||||
, V.display_order
|
||||
, t_V.id_type
|
||||
, V.active AS active_variation
|
||||
/*
|
||||
, 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
|
||||
|
||||
@@ -166,17 +166,17 @@ BEGIN
|
||||
price_GBP_full FLOAT NOT NULL,
|
||||
price_GBP_min FLOAT NOT NULL,
|
||||
*
|
||||
, latency_manufacture INT NOT NULL
|
||||
, latency_manufacture_days INT NOT NULL
|
||||
, quantity_min FLOAT NOT NULL
|
||||
, quantity_max FLOAT NOT NULL
|
||||
, quantity_step FLOAT NOT NULL
|
||||
, quantity_stock FLOAT NOT NULL
|
||||
, is_subscription BIT NOT NULL
|
||||
, id_recurrence_interval INT
|
||||
, CONSTRAINT FK_tmp_Shop_Product_id_recurrence_interval
|
||||
FOREIGN KEY (id_recurrence_interval)
|
||||
REFERENCES Shop_Recurrence_Interval(id_interval)
|
||||
, count_recurrence_interval INT
|
||||
, id_unit_measurement_interval_recurrence INT
|
||||
, CONSTRAINT FK_tmp_Shop_Product_id_unit_measurement_interval_recurrence
|
||||
FOREIGN KEY (id_unit_measurement_interval_recurrence)
|
||||
REFERENCES Shop_Interval_Recurrence(id_interval)
|
||||
, count_interval_recurrence INT
|
||||
, id_stripe_product VARCHAR(100)
|
||||
, product_has_variations INT NOT NULL
|
||||
, can_view BIT
|
||||
|
||||
@@ -480,15 +480,15 @@ BEGIN
|
||||
CURRENCY.code AS code_currency_cost,
|
||||
CURRENCY.symbol AS symbol_currency_cost,
|
||||
PP.profit_local_min,
|
||||
t_P.latency_manufacture,
|
||||
t_P.latency_manufacture_days,
|
||||
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,
|
||||
UM.name_singular AS name_interval_recurrence,
|
||||
UM.name_plural AS name_plural_interval_recurrence,
|
||||
PP.count_interval_recurrence,
|
||||
t_P.display_order_category,
|
||||
t_P.display_order_product,
|
||||
@@ -499,8 +499,8 @@ BEGIN
|
||||
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
|
||||
-- LEFT JOIN Shop_Interval_Recurrence RI ON t_P.id_unit_measurement_interval_recurrence = RI.id_interval
|
||||
LEFT JOIN Shop_Unit_Measurement UM ON PP.id_unit_measurement_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
|
||||
;
|
||||
@@ -764,36 +764,20 @@ 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
|
||||
CALL partsltd_prod.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)
|
||||
);
|
||||
|
||||
select * FROM Shop_User_Eval_Temp;
|
||||
|
||||
@@ -195,13 +195,13 @@ BEGIN
|
||||
P.id_stripe_product,
|
||||
P.is_subscription,
|
||||
LOWER(RI.code) AS name_recurring_interval,
|
||||
P.count_recurrence_interval
|
||||
P.count_interval_recurrence
|
||||
FROM tmp_Shop_Product_Currency_Link t_PCL
|
||||
INNER JOIN Shop_Product P
|
||||
ON t_PCL.id_product = P.id_product
|
||||
AND P.active
|
||||
INNER JOIN Shop_Recurrence_Interval RI
|
||||
ON P.id_recurrence_interval = RI.id_interval
|
||||
INNER JOIN Shop_Interval_Recurrence RI
|
||||
ON P.id_unit_measurement_interval_recurrence = RI.id_interval
|
||||
AND RI.active
|
||||
INNER JOIN Shop_Currency C
|
||||
ON t_PCL.id_currency = C.id_currency
|
||||
|
||||
@@ -196,17 +196,17 @@ BEGIN
|
||||
price_GBP_full FLOAT NOT NULL,
|
||||
price_GBP_min FLOAT NOT NULL,
|
||||
*/
|
||||
latency_manufacture INT NOT NULL,
|
||||
latency_manufacture_days INT NOT NULL,
|
||||
quantity_min FLOAT NOT NULL,
|
||||
quantity_max FLOAT NOT NULL,
|
||||
quantity_step FLOAT NOT NULL,
|
||||
quantity_stock FLOAT NOT NULL,
|
||||
is_subscription BIT NOT NULL,
|
||||
id_recurrence_interval INT,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_recurrence_interval
|
||||
FOREIGN KEY (id_recurrence_interval)
|
||||
REFERENCES Shop_Recurrence_Interval(id_interval),
|
||||
count_recurrence_interval INT,
|
||||
id_unit_measurement_interval_recurrence INT,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_unit_measurement_interval_recurrence
|
||||
FOREIGN KEY (id_unit_measurement_interval_recurrence)
|
||||
REFERENCES Shop_Interval_Recurrence(id_interval),
|
||||
count_interval_recurrence INT,
|
||||
id_stripe_product VARCHAR(100),
|
||||
product_has_variations INT NOT NULL,
|
||||
can_view BIT,
|
||||
@@ -388,14 +388,14 @@ BEGIN
|
||||
price_GBP_VAT_excl,
|
||||
price_GBP_min,
|
||||
*
|
||||
latency_manufacture,
|
||||
latency_manufacture_days,
|
||||
quantity_min,
|
||||
quantity_max,
|
||||
quantity_step,
|
||||
quantity_stock,
|
||||
is_subscription,
|
||||
id_recurrence_interval,
|
||||
count_recurrence_interval,
|
||||
id_unit_measurement_interval_recurrence,
|
||||
count_interval_recurrence,
|
||||
id_stripe_product,
|
||||
product_has_variations
|
||||
*/
|
||||
@@ -420,14 +420,14 @@ BEGIN
|
||||
PP.price_GBP_VAT_excl,
|
||||
PP.price_GBP_min,
|
||||
*
|
||||
PP.latency_manufacture,
|
||||
PP.latency_manufacture_days,
|
||||
PP.quantity_min,
|
||||
PP.quantity_max,
|
||||
PP.quantity_step,
|
||||
PP.quantity_stock,
|
||||
PP.is_subscription,
|
||||
PP.id_recurrence_interval,
|
||||
PP.count_recurrence_interval,
|
||||
PP.id_unit_measurement_interval_recurrence,
|
||||
PP.count_interval_recurrence,
|
||||
PP.id_stripe_product,
|
||||
P.has_variations
|
||||
*/
|
||||
|
||||
@@ -168,17 +168,17 @@ BEGIN
|
||||
price_GBP_min FLOAT NOT NULL,
|
||||
*/
|
||||
/*
|
||||
latency_manufacture INT NOT NULL,
|
||||
latency_manufacture_days INT NOT NULL,
|
||||
quantity_min FLOAT NOT NULL,
|
||||
quantity_max FLOAT NOT NULL,
|
||||
quantity_step FLOAT NOT NULL,
|
||||
quantity_stock FLOAT NOT NULL,
|
||||
is_subscription BIT NOT NULL,
|
||||
id_recurrence_interval INT,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_recurrence_interval
|
||||
FOREIGN KEY (id_recurrence_interval)
|
||||
REFERENCES Shop_Recurrence_Interval(id_interval),
|
||||
count_recurrence_interval INT,
|
||||
id_unit_measurement_interval_recurrence INT,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_unit_measurement_interval_recurrence
|
||||
FOREIGN KEY (id_unit_measurement_interval_recurrence)
|
||||
REFERENCES Shop_Interval_Recurrence(id_interval),
|
||||
count_interval_recurrence INT,
|
||||
id_stripe_product VARCHAR(100),
|
||||
product_has_variations INT NOT NULL,
|
||||
*/
|
||||
@@ -308,14 +308,14 @@ BEGIN
|
||||
price_GBP_VAT_excl,
|
||||
price_GBP_min,
|
||||
*
|
||||
latency_manufacture,
|
||||
latency_manufacture_days,
|
||||
quantity_min,
|
||||
quantity_max,
|
||||
quantity_step,
|
||||
quantity_stock,
|
||||
is_subscription,
|
||||
id_recurrence_interval,
|
||||
count_recurrence_interval,
|
||||
id_unit_measurement_interval_recurrence,
|
||||
count_interval_recurrence,
|
||||
id_stripe_product,
|
||||
product_has_variations
|
||||
*/
|
||||
@@ -340,14 +340,14 @@ BEGIN
|
||||
PP.price_GBP_VAT_excl,
|
||||
PP.price_GBP_min,
|
||||
*
|
||||
PP.latency_manufacture,
|
||||
PP.latency_manufacture_days,
|
||||
PP.quantity_min,
|
||||
PP.quantity_max,
|
||||
PP.quantity_step,
|
||||
PP.quantity_stock,
|
||||
PP.is_subscription,
|
||||
PP.id_recurrence_interval,
|
||||
PP.count_recurrence_interval,
|
||||
PP.id_unit_measurement_interval_recurrence,
|
||||
PP.count_interval_recurrence,
|
||||
PP.id_stripe_product,
|
||||
P.has_variations
|
||||
*/
|
||||
|
||||
@@ -203,17 +203,17 @@ BEGIN
|
||||
price_GBP_min FLOAT NOT NULL,
|
||||
*/
|
||||
/*
|
||||
latency_manufacture INT NOT NULL,
|
||||
latency_manufacture_days INT NOT NULL,
|
||||
quantity_min FLOAT NOT NULL,
|
||||
quantity_max FLOAT NOT NULL,
|
||||
quantity_step FLOAT NOT NULL,
|
||||
quantity_stock FLOAT NOT NULL,
|
||||
is_subscription BIT NOT NULL,
|
||||
id_recurrence_interval INT,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_recurrence_interval
|
||||
FOREIGN KEY (id_recurrence_interval)
|
||||
REFERENCES Shop_Recurrence_Interval(id_interval),
|
||||
count_recurrence_interval INT,
|
||||
id_unit_measurement_interval_recurrence INT,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_unit_measurement_interval_recurrence
|
||||
FOREIGN KEY (id_unit_measurement_interval_recurrence)
|
||||
REFERENCES Shop_Interval_Recurrence(id_interval),
|
||||
count_interval_recurrence INT,
|
||||
id_stripe_product VARCHAR(100),
|
||||
product_has_variations INT NOT NULL,
|
||||
*/
|
||||
@@ -398,14 +398,14 @@ BEGIN
|
||||
price_GBP_VAT_excl,
|
||||
price_GBP_min,
|
||||
*
|
||||
latency_manufacture,
|
||||
latency_manufacture_days,
|
||||
quantity_min,
|
||||
quantity_max,
|
||||
quantity_step,
|
||||
quantity_stock,
|
||||
is_subscription,
|
||||
id_recurrence_interval,
|
||||
count_recurrence_interval,
|
||||
id_unit_measurement_interval_recurrence,
|
||||
count_interval_recurrence,
|
||||
id_stripe_product,
|
||||
product_has_variations
|
||||
*/
|
||||
@@ -430,14 +430,14 @@ BEGIN
|
||||
PP.price_GBP_VAT_excl,
|
||||
PP.price_GBP_min,
|
||||
*
|
||||
PP.latency_manufacture,
|
||||
PP.latency_manufacture_days,
|
||||
PP.quantity_min,
|
||||
PP.quantity_max,
|
||||
PP.quantity_step,
|
||||
PP.quantity_stock,
|
||||
PP.is_subscription,
|
||||
PP.id_recurrence_interval,
|
||||
PP.count_recurrence_interval,
|
||||
PP.id_unit_measurement_interval_recurrence,
|
||||
PP.count_interval_recurrence,
|
||||
PP.id_stripe_product,
|
||||
P.has_variations
|
||||
*/
|
||||
|
||||
@@ -140,13 +140,13 @@ VALUES
|
||||
|
||||
# Unit of Measurement
|
||||
INSERT INTO Shop_Unit_Measurement (
|
||||
name_singular, name_plural, symbol, is_base_unit
|
||||
name_singular, name_plural, symbol, is_base_unit, is_unit_of_distance, is_unit_of_mass, is_unit_of_time, is_unit_of_volume
|
||||
)
|
||||
VALUES
|
||||
('metre', 'metres', 'm', 1),
|
||||
('kilogram', 'kilograms', 'kg', 1),
|
||||
('item', 'items', 'x', 0),
|
||||
('hour', 'hours', 'h', 1)
|
||||
('metre', 'metres', 'm', 1, 1, 0, 0, 0),
|
||||
('kilogram', 'kilograms', 'kg', 1, 0, 1, 0, 0),
|
||||
('item', 'items', 'x', 0, 0, 0, 0, 0),
|
||||
('hour', 'hours', 'h', 1, 0, 0, 1, 0)
|
||||
;
|
||||
|
||||
/*
|
||||
@@ -177,7 +177,7 @@ VALUES
|
||||
|
||||
/*
|
||||
# Recurrence Interval
|
||||
INSERT INTO Shop_Recurrence_Interval (
|
||||
INSERT INTO Shop_Interval_Recurrence (
|
||||
code, name, name_plural
|
||||
)
|
||||
VALUES
|
||||
@@ -248,18 +248,19 @@ INSERT INTO Shop_Product_Permutation (
|
||||
id_currency_cost,
|
||||
profit_local_min,
|
||||
# id_currency_profit_min,
|
||||
latency_manufacture,
|
||||
quantity_min,
|
||||
latency_manufacture_days,
|
||||
id_unit_measurement_quantity,
|
||||
count_unit_measurement_per_quantity_step,
|
||||
quantity_min,
|
||||
quantity_max,
|
||||
quantity_step,
|
||||
quantity_stock,
|
||||
is_subscription,
|
||||
id_interval_recurrence,
|
||||
id_unit_measurement_interval_recurrence,
|
||||
count_interval_recurrence,
|
||||
-- id_access_level_required,
|
||||
id_stripe_product
|
||||
, does_expire_faster_once_unsealed
|
||||
, id_interval_expiration_unsealed
|
||||
, id_unit_measurement_interval_expiration_unsealed
|
||||
, count_interval_expiration_unsealed
|
||||
)
|
||||
VALUES
|
||||
@@ -273,9 +274,10 @@ VALUES
|
||||
# 1,
|
||||
14,
|
||||
1,
|
||||
3,
|
||||
1,
|
||||
3,
|
||||
99,
|
||||
1,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
@@ -295,9 +297,10 @@ VALUES
|
||||
# 1,
|
||||
14,
|
||||
1,
|
||||
3,
|
||||
1,
|
||||
3,
|
||||
99,
|
||||
1,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
@@ -317,9 +320,10 @@ VALUES
|
||||
# 1,
|
||||
14,
|
||||
1,
|
||||
2,
|
||||
1,
|
||||
2,
|
||||
99,
|
||||
1,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
@@ -339,9 +343,10 @@ VALUES
|
||||
# 1,
|
||||
14,
|
||||
1,
|
||||
2,
|
||||
1,
|
||||
2,
|
||||
99,
|
||||
1,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
@@ -361,9 +366,10 @@ VALUES
|
||||
# 1,
|
||||
14,
|
||||
1,
|
||||
2,
|
||||
1,
|
||||
2,
|
||||
99,
|
||||
1,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
@@ -383,9 +389,10 @@ VALUES
|
||||
# 1,
|
||||
14,
|
||||
1,
|
||||
2,
|
||||
1,
|
||||
2,
|
||||
99,
|
||||
1,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
|
||||
@@ -68,8 +68,8 @@ SELECT * FROM Shop_Unit_Measurement_Conversion_Audit;
|
||||
|
||||
/*
|
||||
# Recurrence Interval
|
||||
SELECT * FROM Shop_Recurrence_Interval;
|
||||
SELECT * FROM Shop_Recurrence_Interval_Audit;
|
||||
SELECT * FROM Shop_Interval_Recurrence;
|
||||
SELECT * FROM Shop_Interval_Recurrence_Audit;
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@@ -36,8 +36,8 @@ DROP TABLE IF EXISTS Shop_Variation_Type;
|
||||
DROP TABLE IF EXISTS Shop_Product_Audit;
|
||||
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_Interval_Recurrence_Audit;
|
||||
DROP TABLE IF EXISTS Shop_Interval_Recurrence;
|
||||
|
||||
DROP TABLE IF EXISTS Shop_Product_Category_Audit;
|
||||
DROP TABLE IF EXISTS Shop_Product_Category;
|
||||
@@ -342,7 +342,7 @@ SELECT * FROM Shop_Product_Category_Audit;
|
||||
|
||||
|
||||
# Recurrence Interval
|
||||
CREATE TABLE Shop_Recurrence_Interval (
|
||||
CREATE TABLE Shop_Interval_Recurrence (
|
||||
id_interval INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
code VARCHAR(50),
|
||||
name VARCHAR(255),
|
||||
@@ -350,14 +350,14 @@ CREATE TABLE Shop_Recurrence_Interval (
|
||||
created_on TIMESTAMP,
|
||||
created_by INT,
|
||||
id_change_set INT,
|
||||
CONSTRAINT FK_Shop_Recurrence_Interval_id_change_set
|
||||
CONSTRAINT FK_Shop_Interval_Recurrence_id_change_set
|
||||
FOREIGN KEY (id_change_set)
|
||||
REFERENCES Shop_Product_Change_Set(id_change_set)
|
||||
);
|
||||
|
||||
DELIMITER //
|
||||
CREATE TRIGGER before_insert_Shop_Recurrence_Interval
|
||||
BEFORE INSERT ON Shop_Recurrence_Interval
|
||||
CREATE TRIGGER before_insert_Shop_Interval_Recurrence
|
||||
BEFORE INSERT ON Shop_Interval_Recurrence
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
SET NEW.created_on := IFNULL(NEW.created_on, NOW());
|
||||
@@ -365,28 +365,28 @@ BEGIN
|
||||
END //
|
||||
DELIMITER ;;
|
||||
|
||||
CREATE TABLE Shop_Recurrence_Interval_Audit (
|
||||
CREATE TABLE Shop_Interval_Recurrence_Audit (
|
||||
id_audit INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
id_interval INT NOT NULL,
|
||||
CONSTRAINT FK_Shop_Recurrence_Interval_Audit_id_interval
|
||||
CONSTRAINT FK_Shop_Interval_Recurrence_Audit_id_interval
|
||||
FOREIGN KEY (id_interval)
|
||||
REFERENCES Shop_Recurrence_Interval(id_interval)
|
||||
REFERENCES Shop_Interval_Recurrence(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
|
||||
CONSTRAINT FK_Shop_Interval_Recurrence_Audit_id_change_set
|
||||
FOREIGN KEY (id_change_set)
|
||||
REFERENCES Shop_Product_Change_Set(id_change_set)
|
||||
);
|
||||
|
||||
DELIMITER //
|
||||
CREATE TRIGGER before_update_Shop_Recurrence_Interval
|
||||
BEFORE UPDATE ON Shop_Recurrence_Interval
|
||||
CREATE TRIGGER before_update_Shop_Interval_Recurrence
|
||||
BEFORE UPDATE ON Shop_Interval_Recurrence
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
INSERT INTO Shop_Recurrence_Interval_Audit (
|
||||
INSERT INTO Shop_Interval_Recurrence_Audit (
|
||||
id_interval,
|
||||
name_field,
|
||||
value_prev,
|
||||
@@ -408,7 +408,7 @@ BEGIN
|
||||
END //
|
||||
DELIMITER ;;
|
||||
|
||||
INSERT INTO Shop_Recurrence_Interval (
|
||||
INSERT INTO Shop_Interval_Recurrence (
|
||||
code, name, name_plural
|
||||
)
|
||||
VALUES
|
||||
@@ -417,8 +417,8 @@ VALUES
|
||||
('YEAR', 'Year', 'Years')
|
||||
;
|
||||
|
||||
SELECT * FROM Shop_Recurrence_Interval;
|
||||
SELECT * FROM Shop_Recurrence_Interval_Audit;
|
||||
SELECT * FROM Shop_Interval_Recurrence;
|
||||
SELECT * FROM Shop_Interval_Recurrence_Audit;
|
||||
|
||||
|
||||
|
||||
@@ -439,11 +439,11 @@ CREATE TABLE Shop_Product (
|
||||
quantity_step FLOAT NOT NULL DEFAULT 1,
|
||||
quantity_stock FLOAT NOT NULL DEFAULT 0,
|
||||
is_subscription BIT NOT NULL DEFAULT 0,
|
||||
id_recurrence_interval INT,
|
||||
CONSTRAINT FK_Shop_Product_id_recurrence_interval
|
||||
FOREIGN KEY (id_recurrence_interval)
|
||||
REFERENCES Shop_Recurrence_Interval(id_interval),
|
||||
count_recurrence_interval INT,
|
||||
id_unit_measurement_interval_recurrence INT,
|
||||
CONSTRAINT FK_Shop_Product_id_unit_measurement_interval_recurrence
|
||||
FOREIGN KEY (id_unit_measurement_interval_recurrence)
|
||||
REFERENCES Shop_Interval_Recurrence(id_interval),
|
||||
count_interval_recurrence INT,
|
||||
id_stripe_product VARCHAR(100),
|
||||
id_stripe_price VARCHAR(100),
|
||||
active BIT NOT NULL DEFAULT 1,
|
||||
@@ -534,13 +534,13 @@ BEGIN
|
||||
SELECT NEW.id_product, 'is_subscription', CONVERT(CONVERT(OLD.is_subscription, SIGNED), CHAR), CONVERT(CONVERT(NEW.is_subscription, SIGNED), CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.is_subscription <=> NEW.is_subscription
|
||||
UNION
|
||||
# Changed id_recurrence_interval
|
||||
SELECT NEW.id_product, 'id_recurrence_interval', CONVERT(OLD.id_recurrence_interval, CHAR), CONVERT(NEW.id_recurrence_interval, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.id_recurrence_interval <=> NEW.id_recurrence_interval
|
||||
# Changed id_unit_measurement_interval_recurrence
|
||||
SELECT NEW.id_product, 'id_unit_measurement_interval_recurrence', CONVERT(OLD.id_unit_measurement_interval_recurrence, CHAR), CONVERT(NEW.id_unit_measurement_interval_recurrence, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.id_unit_measurement_interval_recurrence <=> NEW.id_unit_measurement_interval_recurrence
|
||||
UNION
|
||||
# Changed count_recurrence_interval
|
||||
SELECT NEW.id_product, 'count_recurrence_interval', CONVERT(OLD.count_recurrence_interval, CHAR), CONVERT(NEW.count_recurrence_interval, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.count_recurrence_interval <=> NEW.count_recurrence_interval
|
||||
# Changed count_interval_recurrence
|
||||
SELECT NEW.id_product, 'count_interval_recurrence', CONVERT(OLD.count_interval_recurrence, CHAR), CONVERT(NEW.count_interval_recurrence, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.count_interval_recurrence <=> NEW.count_interval_recurrence
|
||||
UNION
|
||||
# Changed id_stripe_product
|
||||
SELECT NEW.id_product, 'id_stripe_product', OLD.id_stripe_product, NEW.id_stripe_product, NEW.id_change_set
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
|
||||
|
||||
|
||||
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Recurrence_Interval';
|
||||
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Interval_Recurrence';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS Shop_Recurrence_Interval (
|
||||
CREATE TABLE IF NOT EXISTS Shop_Interval_Recurrence (
|
||||
id_interval INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
code VARCHAR(50),
|
||||
name VARCHAR(255),
|
||||
@@ -14,7 +14,7 @@ CREATE TABLE IF NOT EXISTS Shop_Recurrence_Interval (
|
||||
created_on TIMESTAMP,
|
||||
created_by INT,
|
||||
id_change_set INT,
|
||||
CONSTRAINT FK_Shop_Recurrence_Interval_id_change_set
|
||||
CONSTRAINT FK_Shop_Interval_Recurrence_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_Recurrence_Interval_Audit';
|
||||
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Interval_Recurrence_Audit';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS Shop_Recurrence_Interval_Audit (
|
||||
CREATE TABLE IF NOT EXISTS Shop_Interval_Recurrence_Audit (
|
||||
id_audit INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
id_interval INT NOT NULL,
|
||||
CONSTRAINT FK_Shop_Recurrence_Interval_Audit_id_interval
|
||||
CONSTRAINT FK_Shop_Interval_Recurrence_Audit_id_interval
|
||||
FOREIGN KEY (id_interval)
|
||||
REFERENCES Shop_Recurrence_Interval(id_interval)
|
||||
REFERENCES Shop_Interval_Recurrence(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
|
||||
CONSTRAINT FK_Shop_Interval_Recurrence_Audit_id_change_set
|
||||
FOREIGN KEY (id_change_set)
|
||||
REFERENCES Shop_Product_Change_Set(id_change_set)
|
||||
);
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
|
||||
|
||||
|
||||
DROP TRIGGER IF EXISTS before_insert_Shop_Recurrence_Interval;
|
||||
DROP TRIGGER IF EXISTS before_update_Shop_Recurrence_Interval;
|
||||
DROP TRIGGER IF EXISTS before_insert_Shop_Interval_Recurrence;
|
||||
DROP TRIGGER IF EXISTS before_update_Shop_Interval_Recurrence;
|
||||
|
||||
|
||||
DELIMITER //
|
||||
CREATE TRIGGER before_insert_Shop_Recurrence_Interval
|
||||
BEFORE INSERT ON Shop_Recurrence_Interval
|
||||
CREATE TRIGGER before_insert_Shop_Interval_Recurrence
|
||||
BEFORE INSERT ON Shop_Interval_Recurrence
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
SET NEW.created_on := IFNULL(NEW.created_on, NOW());
|
||||
@@ -20,8 +20,8 @@ DELIMITER ;;
|
||||
|
||||
|
||||
DELIMITER //
|
||||
CREATE TRIGGER before_update_Shop_Recurrence_Interval
|
||||
BEFORE UPDATE ON Shop_Recurrence_Interval
|
||||
CREATE TRIGGER before_update_Shop_Interval_Recurrence
|
||||
BEFORE UPDATE ON Shop_Interval_Recurrence
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
IF OLD.id_change_set <=> NEW.id_change_set THEN
|
||||
@@ -29,7 +29,7 @@ BEGIN
|
||||
SET MESSAGE_TEXT = 'New change Set ID must be provided.';
|
||||
END IF;
|
||||
|
||||
INSERT INTO Shop_Recurrence_Interval_Audit (
|
||||
INSERT INTO Shop_Interval_Recurrence_Audit (
|
||||
id_interval,
|
||||
name_field,
|
||||
value_prev,
|
||||
|
||||
@@ -309,14 +309,14 @@ BEGIN
|
||||
P.quantity_stock,
|
||||
P.id_stripe_product,
|
||||
P.is_subscription,
|
||||
RI.name AS name_recurrence_interval,
|
||||
RI.name_plural AS name_plural_recurrence_interval,
|
||||
P.count_recurrence_interval
|
||||
RI.name AS name_interval_recurrence,
|
||||
RI.name_plural AS name_plural_interval_recurrence,
|
||||
P.count_interval_recurrence
|
||||
FROM tmp_Shop_Product t_P
|
||||
INNER JOIN Shop_Product P
|
||||
ON t_P.id_product = P.id_product
|
||||
LEFT JOIN Shop_Recurrence_Interval RI
|
||||
ON P.id_recurrence_interval = RI.id_interval
|
||||
LEFT JOIN Shop_Interval_Recurrence RI
|
||||
ON P.id_unit_measurement_interval_recurrence = RI.id_interval
|
||||
WHERE ISNULL(t_P.id_permutation)
|
||||
ORDER BY t_P.display_order
|
||||
;
|
||||
@@ -336,17 +336,17 @@ BEGIN
|
||||
P.quantity_stock,
|
||||
P.id_stripe_product,
|
||||
P.is_subscription,
|
||||
RI.name AS name_recurrence_interval,
|
||||
RI.name_plural AS name_plural_recurrence_interval,
|
||||
P.count_recurrence_interval
|
||||
RI.name AS name_interval_recurrence,
|
||||
RI.name_plural AS name_plural_interval_recurrence,
|
||||
P.count_interval_recurrence
|
||||
FROM tmp_Shop_Product t_P
|
||||
INNER JOIN Shop_Product_Permutation PP
|
||||
ON t_P.id_permutation = PP.id_permutation
|
||||
AND PP.active
|
||||
INNER JOIN Shop_Product P
|
||||
ON PP.id_product = P.id_product
|
||||
LEFT JOIN Shop_Recurrence_Interval RI
|
||||
ON P.id_recurrence_interval = RI.id_interval
|
||||
LEFT JOIN Shop_Interval_Recurrence RI
|
||||
ON P.id_unit_measurement_interval_recurrence = RI.id_interval
|
||||
WHERE NOT ISNULL(t_P.id_permutation)
|
||||
ORDER BY t_P.display_order
|
||||
;
|
||||
|
||||
@@ -1964,11 +1964,11 @@ DELIMITER ;;;
|
||||
SIGNAL SQLSTATE '45000'
|
||||
SET MESSAGE_TEXT = 'Product must have subscription status or variations (with subscription statuses).';
|
||||
END IF;
|
||||
IF ISNULL(NEW.id_recurrence_interval) THEN
|
||||
IF ISNULL(NEW.id_unit_measurement_interval_recurrence) THEN
|
||||
SIGNAL SQLSTATE '45000'
|
||||
SET MESSAGE_TEXT = 'Product must have recurrence interval or variations (with recurrence intervals).';
|
||||
END IF;
|
||||
IF ISNULL(NEW.count_recurrence_interval) THEN
|
||||
IF ISNULL(NEW.count_interval_recurrence) THEN
|
||||
SIGNAL SQLSTATE '45000'
|
||||
SET MESSAGE_TEXT = 'Product must have recurrence interval count or variations (with recurrence interval counts).';
|
||||
END IF;
|
||||
@@ -2038,13 +2038,13 @@ DELIMITER ;;;
|
||||
SELECT NEW.id_product, 'is_subscription', CONVERT(CONVERT(OLD.is_subscription, SIGNED), CHAR), CONVERT(CONVERT(NEW.is_subscription, SIGNED), CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.is_subscription <=> NEW.is_subscription
|
||||
UNION
|
||||
# Changed id_recurrence_interval
|
||||
SELECT NEW.id_product, 'id_recurrence_interval', CONVERT(OLD.id_recurrence_interval, CHAR), CONVERT(NEW.id_recurrence_interval, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.id_recurrence_interval <=> NEW.id_recurrence_interval
|
||||
# Changed id_unit_measurement_interval_recurrence
|
||||
SELECT NEW.id_product, 'id_unit_measurement_interval_recurrence', CONVERT(OLD.id_unit_measurement_interval_recurrence, CHAR), CONVERT(NEW.id_unit_measurement_interval_recurrence, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.id_unit_measurement_interval_recurrence <=> NEW.id_unit_measurement_interval_recurrence
|
||||
UNION
|
||||
# Changed count_recurrence_interval
|
||||
SELECT NEW.id_product, 'count_recurrence_interval', CONVERT(OLD.count_recurrence_interval, CHAR), CONVERT(NEW.count_recurrence_interval, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.count_recurrence_interval <=> NEW.count_recurrence_interval
|
||||
# Changed count_interval_recurrence
|
||||
SELECT NEW.id_product, 'count_interval_recurrence', CONVERT(OLD.count_interval_recurrence, CHAR), CONVERT(NEW.count_interval_recurrence, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.count_interval_recurrence <=> NEW.count_interval_recurrence
|
||||
UNION
|
||||
# Changed id_access_level_required
|
||||
SELECT NEW.id_product, 'id_access_level_required', CONVERT(OLD.id_access_level_required, CHAR), CONVERT(NEW.id_access_level_required, CHAR), NEW.id_change_set
|
||||
@@ -2674,14 +2674,14 @@ CREATE TABLE `shop_product_permutation` (
|
||||
`id_currency_cost_manufacturing` int NOT NULL,
|
||||
`profit_local_min` float NOT NULL,
|
||||
`id_currency_profit_min` int NOT NULL,
|
||||
`latency_manufacture` int NOT NULL,
|
||||
`latency_manufacture_days` int NOT NULL,
|
||||
`quantity_min` float NOT NULL,
|
||||
`quantity_max` float NOT NULL,
|
||||
`quantity_step` float NOT NULL,
|
||||
`quantity_stock` float NOT NULL,
|
||||
`is_subscription` bit(1) NOT NULL,
|
||||
`id_recurrence_interval` int DEFAULT NULL,
|
||||
`count_recurrence_interval` int DEFAULT NULL,
|
||||
`id_unit_measurement_interval_recurrence` int DEFAULT NULL,
|
||||
`count_interval_recurrence` int DEFAULT NULL,
|
||||
`id_access_level_required` int NOT NULL,
|
||||
`id_stripe_product` varchar(100) DEFAULT NULL,
|
||||
`active` bit(1) NOT NULL DEFAULT b'1',
|
||||
@@ -2691,11 +2691,11 @@ CREATE TABLE `shop_product_permutation` (
|
||||
`id_change_set` int DEFAULT NULL,
|
||||
PRIMARY KEY (`id_permutation`),
|
||||
KEY `FK_Shop_Product_Variation_Link_id_product` (`id_product`),
|
||||
KEY `FK_Shop_Product_Permutation_id_recurrence_interval` (`id_recurrence_interval`),
|
||||
KEY `FK_Shop_Product_Permutation_id_unit_measurement_interval_recurrence` (`id_unit_measurement_interval_recurrence`),
|
||||
KEY `FK_Shop_Product_Permutation_id_access_level_required` (`id_access_level_required`),
|
||||
KEY `FK_Shop_Product_Variation_Link_id_change_set` (`id_change_set`),
|
||||
CONSTRAINT `FK_Shop_Product_Permutation_id_access_level_required` FOREIGN KEY (`id_access_level_required`) REFERENCES `shop_access_level` (`id_access_level`),
|
||||
CONSTRAINT `FK_Shop_Product_Permutation_id_recurrence_interval` FOREIGN KEY (`id_recurrence_interval`) REFERENCES `shop_recurrence_interval` (`id_interval`),
|
||||
CONSTRAINT `FK_Shop_Product_Permutation_id_unit_measurement_interval_recurrence` FOREIGN KEY (`id_unit_measurement_interval_recurrence`) REFERENCES `shop_interval_recurrence` (`id_interval`),
|
||||
CONSTRAINT `FK_Shop_Product_Variation_Link_id_change_set` FOREIGN KEY (`id_change_set`) REFERENCES `shop_product_change_set` (`id_change_set`),
|
||||
CONSTRAINT `FK_Shop_Product_Variation_Link_id_product` FOREIGN KEY (`id_product`) REFERENCES `shop_product` (`id_product`) ON UPDATE RESTRICT
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||||
@@ -2794,9 +2794,9 @@ DELIMITER ;;;
|
||||
WHERE NOT (OLD.price_GBP_min <=> NEW.price_GBP_min)
|
||||
UNION
|
||||
*/
|
||||
# Changed latency_manufacture
|
||||
SELECT NEW.id_product, 'latency_manufacture', CONVERT(OLD.latency_manufacture, CHAR), CONVERT(NEW.latency_manufacture, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.latency_manufacture <=> NEW.latency_manufacture
|
||||
# Changed latency_manufacture_days
|
||||
SELECT NEW.id_product, 'latency_manufacture_days', CONVERT(OLD.latency_manufacture_days, CHAR), CONVERT(NEW.latency_manufacture_days, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.latency_manufacture_days <=> NEW.latency_manufacture_days
|
||||
UNION
|
||||
# Changed quantity_min
|
||||
SELECT NEW.id_product, 'quantity_min', CONVERT(OLD.quantity_min, CHAR), CONVERT(NEW.quantity_min, CHAR), NEW.id_change_set
|
||||
@@ -2818,13 +2818,13 @@ DELIMITER ;;;
|
||||
SELECT NEW.id_product, 'is_subscription', CONVERT(CONVERT(OLD.is_subscription, SIGNED), CHAR), CONVERT(CONVERT(NEW.is_subscription, SIGNED), CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.is_subscription <=> NEW.is_subscription
|
||||
UNION
|
||||
# Changed id_recurrence_interval
|
||||
SELECT NEW.id_product, 'id_recurrence_interval', CONVERT(OLD.id_recurrence_interval, CHAR), CONVERT(NEW.id_recurrence_interval, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.id_recurrence_interval <=> NEW.id_recurrence_interval
|
||||
# Changed id_unit_measurement_interval_recurrence
|
||||
SELECT NEW.id_product, 'id_unit_measurement_interval_recurrence', CONVERT(OLD.id_unit_measurement_interval_recurrence, CHAR), CONVERT(NEW.id_unit_measurement_interval_recurrence, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.id_unit_measurement_interval_recurrence <=> NEW.id_unit_measurement_interval_recurrence
|
||||
UNION
|
||||
# Changed count_recurrence_interval
|
||||
SELECT NEW.id_product, 'count_recurrence_interval', CONVERT(OLD.count_recurrence_interval, CHAR), CONVERT(NEW.count_recurrence_interval, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.count_recurrence_interval <=> NEW.count_recurrence_interval
|
||||
# Changed count_interval_recurrence
|
||||
SELECT NEW.id_product, 'count_interval_recurrence', CONVERT(OLD.count_interval_recurrence, CHAR), CONVERT(NEW.count_interval_recurrence, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.count_interval_recurrence <=> NEW.count_interval_recurrence
|
||||
UNION
|
||||
# Changed id_stripe_product
|
||||
SELECT NEW.id_permutation, 'id_stripe_product', OLD.id_stripe_product, NEW.id_stripe_product, NEW.id_change_set
|
||||
@@ -3012,13 +3012,13 @@ LOCK TABLES `shop_product_permutation_variation_link_audit` WRITE;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `shop_recurrence_interval`
|
||||
-- Table structure for table `shop_interval_recurrence`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `shop_recurrence_interval`;
|
||||
DROP TABLE IF EXISTS `shop_interval_recurrence`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!50503 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `shop_recurrence_interval` (
|
||||
CREATE TABLE `shop_interval_recurrence` (
|
||||
`id_interval` int NOT NULL AUTO_INCREMENT,
|
||||
`code` varchar(50) DEFAULT NULL,
|
||||
`name` varchar(255) DEFAULT NULL,
|
||||
@@ -3028,19 +3028,19 @@ CREATE TABLE `shop_recurrence_interval` (
|
||||
`created_by` varchar(100) DEFAULT NULL,
|
||||
`id_change_set` int DEFAULT NULL,
|
||||
PRIMARY KEY (`id_interval`),
|
||||
KEY `FK_Shop_Recurrence_Interval_id_change_set` (`id_change_set`),
|
||||
CONSTRAINT `FK_Shop_Recurrence_Interval_id_change_set` FOREIGN KEY (`id_change_set`) REFERENCES `shop_product_change_set` (`id_change_set`)
|
||||
KEY `FK_Shop_Interval_Recurrence_id_change_set` (`id_change_set`),
|
||||
CONSTRAINT `FK_Shop_Interval_Recurrence_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 */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `shop_recurrence_interval`
|
||||
-- Dumping data for table `shop_interval_recurrence`
|
||||
--
|
||||
|
||||
LOCK TABLES `shop_recurrence_interval` WRITE;
|
||||
/*!40000 ALTER TABLE `shop_recurrence_interval` DISABLE KEYS */;
|
||||
INSERT INTO `shop_recurrence_interval` VALUES (1,'WEEK','Week','Weeks',_binary '','2024-04-28 19:03:07','root@localhost',NULL),(2,'MONTH','Month','Months',_binary '','2024-04-28 19:03:07','root@localhost',NULL),(3,'YEAR','Year','Years',_binary '','2024-04-28 19:03:07','root@localhost',NULL);
|
||||
/*!40000 ALTER TABLE `shop_recurrence_interval` ENABLE KEYS */;
|
||||
LOCK TABLES `shop_interval_recurrence` WRITE;
|
||||
/*!40000 ALTER TABLE `shop_interval_recurrence` DISABLE KEYS */;
|
||||
INSERT INTO `shop_interval_recurrence` VALUES (1,'WEEK','Week','Weeks',_binary '','2024-04-28 19:03:07','root@localhost',NULL),(2,'MONTH','Month','Months',_binary '','2024-04-28 19:03:07','root@localhost',NULL),(3,'YEAR','Year','Years',_binary '','2024-04-28 19:03:07','root@localhost',NULL);
|
||||
/*!40000 ALTER TABLE `shop_interval_recurrence` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
|
||||
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
|
||||
@@ -3051,7 +3051,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_Recurrence_Interval` BEFORE INSERT ON `shop_recurrence_interval` FOR EACH ROW BEGIN
|
||||
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `before_insert_Shop_Interval_Recurrence` BEFORE INSERT ON `shop_interval_recurrence` FOR EACH ROW BEGIN
|
||||
SET NEW.created_on := IFNULL(NEW.created_on, NOW());
|
||||
SET NEW.created_by := IFNULL(NEW.created_by, IFNULL((SELECT id_user FROM Shop_User WHERE firstname = CURRENT_USER()), -1));
|
||||
END */;;
|
||||
@@ -3069,13 +3069,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_Recurrence_Interval` BEFORE UPDATE ON `shop_recurrence_interval` FOR EACH ROW BEGIN
|
||||
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `before_update_Shop_Interval_Recurrence` BEFORE UPDATE ON `shop_interval_recurrence` 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 (
|
||||
INSERT INTO Shop_Interval_Recurrence_Audit (
|
||||
id_interval,
|
||||
name_field,
|
||||
value_prev,
|
||||
@@ -3106,13 +3106,13 @@ DELIMITER ;;
|
||||
/*!50003 SET collation_connection = @saved_col_connection */ ;
|
||||
|
||||
--
|
||||
-- Table structure for table `shop_recurrence_interval_audit`
|
||||
-- Table structure for table `shop_interval_recurrence_audit`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `shop_recurrence_interval_audit`;
|
||||
DROP TABLE IF EXISTS `shop_interval_recurrence_audit`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!50503 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `shop_recurrence_interval_audit` (
|
||||
CREATE TABLE `shop_interval_recurrence_audit` (
|
||||
`id_audit` int NOT NULL AUTO_INCREMENT,
|
||||
`id_interval` int NOT NULL,
|
||||
`name_field` varchar(50) DEFAULT NULL,
|
||||
@@ -3120,20 +3120,20 @@ CREATE TABLE `shop_recurrence_interval_audit` (
|
||||
`value_new` varchar(256) DEFAULT NULL,
|
||||
`id_change_set` int NOT NULL,
|
||||
PRIMARY KEY (`id_audit`),
|
||||
KEY `FK_Shop_Recurrence_Interval_Audit_id_interval` (`id_interval`),
|
||||
KEY `FK_Shop_Recurrence_Interval_Audit_id_change_set` (`id_change_set`),
|
||||
CONSTRAINT `FK_Shop_Recurrence_Interval_Audit_id_change_set` FOREIGN KEY (`id_change_set`) REFERENCES `shop_product_change_set` (`id_change_set`),
|
||||
CONSTRAINT `FK_Shop_Recurrence_Interval_Audit_id_interval` FOREIGN KEY (`id_interval`) REFERENCES `shop_recurrence_interval` (`id_interval`) ON UPDATE RESTRICT
|
||||
KEY `FK_Shop_Interval_Recurrence_Audit_id_interval` (`id_interval`),
|
||||
KEY `FK_Shop_Interval_Recurrence_Audit_id_change_set` (`id_change_set`),
|
||||
CONSTRAINT `FK_Shop_Interval_Recurrence_Audit_id_change_set` FOREIGN KEY (`id_change_set`) REFERENCES `shop_product_change_set` (`id_change_set`),
|
||||
CONSTRAINT `FK_Shop_Interval_Recurrence_Audit_id_interval` FOREIGN KEY (`id_interval`) REFERENCES `shop_interval_recurrence` (`id_interval`) ON UPDATE RESTRICT
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `shop_recurrence_interval_audit`
|
||||
-- Dumping data for table `shop_interval_recurrence_audit`
|
||||
--
|
||||
|
||||
LOCK TABLES `shop_recurrence_interval_audit` WRITE;
|
||||
/*!40000 ALTER TABLE `shop_recurrence_interval_audit` DISABLE KEYS */;
|
||||
/*!40000 ALTER TABLE `shop_recurrence_interval_audit` ENABLE KEYS */;
|
||||
LOCK TABLES `shop_interval_recurrence_audit` WRITE;
|
||||
/*!40000 ALTER TABLE `shop_interval_recurrence_audit` DISABLE KEYS */;
|
||||
/*!40000 ALTER TABLE `shop_interval_recurrence_audit` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
@@ -6110,17 +6110,17 @@ BEGIN
|
||||
price_GBP_full FLOAT NOT NULL,
|
||||
price_GBP_min FLOAT NOT NULL,
|
||||
*/
|
||||
latency_manufacture INT NOT NULL,
|
||||
latency_manufacture_days INT NOT NULL,
|
||||
quantity_min FLOAT NOT NULL,
|
||||
quantity_max FLOAT NOT NULL,
|
||||
quantity_step FLOAT NOT NULL,
|
||||
quantity_stock FLOAT NOT NULL,
|
||||
is_subscription BIT NOT NULL,
|
||||
id_recurrence_interval INT,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_recurrence_interval
|
||||
FOREIGN KEY (id_recurrence_interval)
|
||||
REFERENCES Shop_Recurrence_Interval(id_interval),
|
||||
count_recurrence_interval INT,
|
||||
id_unit_measurement_interval_recurrence INT,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_unit_measurement_interval_recurrence
|
||||
FOREIGN KEY (id_unit_measurement_interval_recurrence)
|
||||
REFERENCES Shop_Interval_Recurrence(id_interval),
|
||||
count_interval_recurrence INT,
|
||||
id_stripe_product VARCHAR(100),
|
||||
product_has_variations INT NOT NULL,
|
||||
can_view BIT,
|
||||
@@ -6224,14 +6224,14 @@ BEGIN
|
||||
price_GBP_VAT_excl,
|
||||
price_GBP_min,
|
||||
*/
|
||||
latency_manufacture,
|
||||
latency_manufacture_days,
|
||||
quantity_min,
|
||||
quantity_max,
|
||||
quantity_step,
|
||||
quantity_stock,
|
||||
is_subscription,
|
||||
id_recurrence_interval,
|
||||
count_recurrence_interval,
|
||||
id_unit_measurement_interval_recurrence,
|
||||
count_interval_recurrence,
|
||||
id_stripe_product,
|
||||
product_has_variations
|
||||
)
|
||||
@@ -6254,14 +6254,14 @@ BEGIN
|
||||
PP.price_GBP_VAT_excl,
|
||||
PP.price_GBP_min,
|
||||
*/
|
||||
PP.latency_manufacture,
|
||||
PP.latency_manufacture_days,
|
||||
PP.quantity_min,
|
||||
PP.quantity_max,
|
||||
PP.quantity_step,
|
||||
PP.quantity_stock,
|
||||
PP.is_subscription,
|
||||
PP.id_recurrence_interval,
|
||||
PP.count_recurrence_interval,
|
||||
PP.id_unit_measurement_interval_recurrence,
|
||||
PP.count_interval_recurrence,
|
||||
PP.id_stripe_product,
|
||||
P.has_variations
|
||||
FROM Shop_Product P
|
||||
@@ -6705,16 +6705,16 @@ BEGIN
|
||||
t_P.description,
|
||||
P.has_variations,
|
||||
P.id_category,
|
||||
t_P.latency_manufacture,
|
||||
t_P.latency_manufacture_days,
|
||||
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,
|
||||
RI.name AS name_recurrence_interval,
|
||||
RI.name_plural AS name_plural_recurrence_interval,
|
||||
t_P.count_recurrence_interval,
|
||||
RI.name AS name_interval_recurrence,
|
||||
RI.name_plural AS name_plural_interval_recurrence,
|
||||
t_P.count_interval_recurrence,
|
||||
t_P.display_order_category,
|
||||
t_P.display_order_product,
|
||||
t_P.display_order_permutation,
|
||||
@@ -6724,8 +6724,8 @@ BEGIN
|
||||
FROM tmp_Shop_Product t_P
|
||||
INNER JOIN Shop_Product P
|
||||
ON t_P.id_product = P.id_product
|
||||
LEFT JOIN Shop_Recurrence_Interval RI
|
||||
ON t_P.id_recurrence_interval = RI.id_interval
|
||||
LEFT JOIN Shop_Interval_Recurrence RI
|
||||
ON t_P.id_unit_measurement_interval_recurrence = RI.id_interval
|
||||
ORDER BY t_P.rank_permutation
|
||||
;
|
||||
|
||||
@@ -7206,13 +7206,13 @@ BEGIN
|
||||
P.id_stripe_product,
|
||||
P.is_subscription,
|
||||
LOWER(RI.code) AS name_recurring_interval,
|
||||
P.count_recurrence_interval
|
||||
P.count_interval_recurrence
|
||||
FROM tmp_Shop_Product_Currency_Link t_PCL
|
||||
INNER JOIN Shop_Product P
|
||||
ON t_PCL.id_product = P.id_product
|
||||
AND P.active
|
||||
INNER JOIN Shop_Recurrence_Interval RI
|
||||
ON P.id_recurrence_interval = RI.id_interval
|
||||
INNER JOIN Shop_Interval_Recurrence RI
|
||||
ON P.id_unit_measurement_interval_recurrence = RI.id_interval
|
||||
AND RI.active
|
||||
INNER JOIN Shop_Currency C
|
||||
ON t_PCL.id_currency = C.id_currency
|
||||
|
||||
@@ -1964,11 +1964,11 @@ DELIMITER ;;;
|
||||
SIGNAL SQLSTATE '45000'
|
||||
SET MESSAGE_TEXT = 'Product must have subscription status or variations (with subscription statuses).';
|
||||
END IF;
|
||||
IF ISNULL(NEW.id_recurrence_interval) THEN
|
||||
IF ISNULL(NEW.id_unit_measurement_interval_recurrence) THEN
|
||||
SIGNAL SQLSTATE '45000'
|
||||
SET MESSAGE_TEXT = 'Product must have recurrence interval or variations (with recurrence intervals).';
|
||||
END IF;
|
||||
IF ISNULL(NEW.count_recurrence_interval) THEN
|
||||
IF ISNULL(NEW.count_interval_recurrence) THEN
|
||||
SIGNAL SQLSTATE '45000'
|
||||
SET MESSAGE_TEXT = 'Product must have recurrence interval count or variations (with recurrence interval counts).';
|
||||
END IF;
|
||||
@@ -2038,13 +2038,13 @@ DELIMITER ;;;
|
||||
SELECT NEW.id_product, 'is_subscription', CONVERT(CONVERT(OLD.is_subscription, SIGNED), CHAR), CONVERT(CONVERT(NEW.is_subscription, SIGNED), CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.is_subscription <=> NEW.is_subscription
|
||||
UNION
|
||||
# Changed id_recurrence_interval
|
||||
SELECT NEW.id_product, 'id_recurrence_interval', CONVERT(OLD.id_recurrence_interval, CHAR), CONVERT(NEW.id_recurrence_interval, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.id_recurrence_interval <=> NEW.id_recurrence_interval
|
||||
# Changed id_unit_measurement_interval_recurrence
|
||||
SELECT NEW.id_product, 'id_unit_measurement_interval_recurrence', CONVERT(OLD.id_unit_measurement_interval_recurrence, CHAR), CONVERT(NEW.id_unit_measurement_interval_recurrence, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.id_unit_measurement_interval_recurrence <=> NEW.id_unit_measurement_interval_recurrence
|
||||
UNION
|
||||
# Changed count_recurrence_interval
|
||||
SELECT NEW.id_product, 'count_recurrence_interval', CONVERT(OLD.count_recurrence_interval, CHAR), CONVERT(NEW.count_recurrence_interval, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.count_recurrence_interval <=> NEW.count_recurrence_interval
|
||||
# Changed count_interval_recurrence
|
||||
SELECT NEW.id_product, 'count_interval_recurrence', CONVERT(OLD.count_interval_recurrence, CHAR), CONVERT(NEW.count_interval_recurrence, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.count_interval_recurrence <=> NEW.count_interval_recurrence
|
||||
UNION
|
||||
# Changed id_access_level_required
|
||||
SELECT NEW.id_product, 'id_access_level_required', CONVERT(OLD.id_access_level_required, CHAR), CONVERT(NEW.id_access_level_required, CHAR), NEW.id_change_set
|
||||
@@ -2674,14 +2674,14 @@ CREATE TABLE `shop_product_permutation` (
|
||||
`id_currency_cost_manufacturing` int NOT NULL,
|
||||
`profit_local_min` float NOT NULL,
|
||||
`id_currency_profit_min` int NOT NULL,
|
||||
`latency_manufacture` int NOT NULL,
|
||||
`latency_manufacture_days` int NOT NULL,
|
||||
`quantity_min` float NOT NULL,
|
||||
`quantity_max` float NOT NULL,
|
||||
`quantity_step` float NOT NULL,
|
||||
`quantity_stock` float NOT NULL,
|
||||
`is_subscription` bit(1) NOT NULL,
|
||||
`id_recurrence_interval` int DEFAULT NULL,
|
||||
`count_recurrence_interval` int DEFAULT NULL,
|
||||
`id_unit_measurement_interval_recurrence` int DEFAULT NULL,
|
||||
`count_interval_recurrence` int DEFAULT NULL,
|
||||
`id_access_level_required` int NOT NULL,
|
||||
`id_stripe_product` varchar(100) DEFAULT NULL,
|
||||
`active` bit(1) NOT NULL DEFAULT b'1',
|
||||
@@ -2691,11 +2691,11 @@ CREATE TABLE `shop_product_permutation` (
|
||||
`id_change_set` int DEFAULT NULL,
|
||||
PRIMARY KEY (`id_permutation`),
|
||||
KEY `FK_Shop_Product_Variation_Link_id_product` (`id_product`),
|
||||
KEY `FK_Shop_Product_Permutation_id_recurrence_interval` (`id_recurrence_interval`),
|
||||
KEY `FK_Shop_Product_Permutation_id_unit_measurement_interval_recurrence` (`id_unit_measurement_interval_recurrence`),
|
||||
KEY `FK_Shop_Product_Permutation_id_access_level_required` (`id_access_level_required`),
|
||||
KEY `FK_Shop_Product_Variation_Link_id_change_set` (`id_change_set`),
|
||||
CONSTRAINT `FK_Shop_Product_Permutation_id_access_level_required` FOREIGN KEY (`id_access_level_required`) REFERENCES `shop_access_level` (`id_access_level`),
|
||||
CONSTRAINT `FK_Shop_Product_Permutation_id_recurrence_interval` FOREIGN KEY (`id_recurrence_interval`) REFERENCES `shop_recurrence_interval` (`id_interval`),
|
||||
CONSTRAINT `FK_Shop_Product_Permutation_id_unit_measurement_interval_recurrence` FOREIGN KEY (`id_unit_measurement_interval_recurrence`) REFERENCES `shop_interval_recurrence` (`id_interval`),
|
||||
CONSTRAINT `FK_Shop_Product_Variation_Link_id_change_set` FOREIGN KEY (`id_change_set`) REFERENCES `shop_product_change_set` (`id_change_set`),
|
||||
CONSTRAINT `FK_Shop_Product_Variation_Link_id_product` FOREIGN KEY (`id_product`) REFERENCES `shop_product` (`id_product`) ON UPDATE RESTRICT
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
@@ -2794,9 +2794,9 @@ DELIMITER ;;;
|
||||
WHERE NOT (OLD.price_GBP_min <=> NEW.price_GBP_min)
|
||||
UNION
|
||||
*/
|
||||
# Changed latency_manufacture
|
||||
SELECT NEW.id_product, 'latency_manufacture', CONVERT(OLD.latency_manufacture, CHAR), CONVERT(NEW.latency_manufacture, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.latency_manufacture <=> NEW.latency_manufacture
|
||||
# Changed latency_manufacture_days
|
||||
SELECT NEW.id_product, 'latency_manufacture_days', CONVERT(OLD.latency_manufacture_days, CHAR), CONVERT(NEW.latency_manufacture_days, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.latency_manufacture_days <=> NEW.latency_manufacture_days
|
||||
UNION
|
||||
# Changed quantity_min
|
||||
SELECT NEW.id_product, 'quantity_min', CONVERT(OLD.quantity_min, CHAR), CONVERT(NEW.quantity_min, CHAR), NEW.id_change_set
|
||||
@@ -2818,13 +2818,13 @@ DELIMITER ;;;
|
||||
SELECT NEW.id_product, 'is_subscription', CONVERT(CONVERT(OLD.is_subscription, SIGNED), CHAR), CONVERT(CONVERT(NEW.is_subscription, SIGNED), CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.is_subscription <=> NEW.is_subscription
|
||||
UNION
|
||||
# Changed id_recurrence_interval
|
||||
SELECT NEW.id_product, 'id_recurrence_interval', CONVERT(OLD.id_recurrence_interval, CHAR), CONVERT(NEW.id_recurrence_interval, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.id_recurrence_interval <=> NEW.id_recurrence_interval
|
||||
# Changed id_unit_measurement_interval_recurrence
|
||||
SELECT NEW.id_product, 'id_unit_measurement_interval_recurrence', CONVERT(OLD.id_unit_measurement_interval_recurrence, CHAR), CONVERT(NEW.id_unit_measurement_interval_recurrence, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.id_unit_measurement_interval_recurrence <=> NEW.id_unit_measurement_interval_recurrence
|
||||
UNION
|
||||
# Changed count_recurrence_interval
|
||||
SELECT NEW.id_product, 'count_recurrence_interval', CONVERT(OLD.count_recurrence_interval, CHAR), CONVERT(NEW.count_recurrence_interval, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.count_recurrence_interval <=> NEW.count_recurrence_interval
|
||||
# Changed count_interval_recurrence
|
||||
SELECT NEW.id_product, 'count_interval_recurrence', CONVERT(OLD.count_interval_recurrence, CHAR), CONVERT(NEW.count_interval_recurrence, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.count_interval_recurrence <=> NEW.count_interval_recurrence
|
||||
UNION
|
||||
# Changed id_stripe_product
|
||||
SELECT NEW.id_permutation, 'id_stripe_product', OLD.id_stripe_product, NEW.id_stripe_product, NEW.id_change_set
|
||||
@@ -3012,13 +3012,13 @@ LOCK TABLES `shop_product_permutation_variation_link_audit` WRITE;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `shop_recurrence_interval`
|
||||
-- Table structure for table `shop_interval_recurrence`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `shop_recurrence_interval`;
|
||||
DROP TABLE IF EXISTS `shop_interval_recurrence`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!50503 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `shop_recurrence_interval` (
|
||||
CREATE TABLE `shop_interval_recurrence` (
|
||||
`id_interval` int NOT NULL AUTO_INCREMENT,
|
||||
`code` varchar(50) DEFAULT NULL,
|
||||
`name` varchar(255) DEFAULT NULL,
|
||||
@@ -3028,19 +3028,19 @@ CREATE TABLE `shop_recurrence_interval` (
|
||||
`created_by` varchar(100) DEFAULT NULL,
|
||||
`id_change_set` int DEFAULT NULL,
|
||||
PRIMARY KEY (`id_interval`),
|
||||
KEY `FK_Shop_Recurrence_Interval_id_change_set` (`id_change_set`),
|
||||
CONSTRAINT `FK_Shop_Recurrence_Interval_id_change_set` FOREIGN KEY (`id_change_set`) REFERENCES `shop_product_change_set` (`id_change_set`)
|
||||
KEY `FK_Shop_Interval_Recurrence_id_change_set` (`id_change_set`),
|
||||
CONSTRAINT `FK_Shop_Interval_Recurrence_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 */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `shop_recurrence_interval`
|
||||
-- Dumping data for table `shop_interval_recurrence`
|
||||
--
|
||||
|
||||
LOCK TABLES `shop_recurrence_interval` WRITE;
|
||||
/*!40000 ALTER TABLE `shop_recurrence_interval` DISABLE KEYS */;
|
||||
INSERT INTO `shop_recurrence_interval` VALUES (1,'WEEK','Week','Weeks',_binary '','2024-04-28 19:03:07','root@localhost',NULL),(2,'MONTH','Month','Months',_binary '','2024-04-28 19:03:07','root@localhost',NULL),(3,'YEAR','Year','Years',_binary '','2024-04-28 19:03:07','root@localhost',NULL);
|
||||
/*!40000 ALTER TABLE `shop_recurrence_interval` ENABLE KEYS */;
|
||||
LOCK TABLES `shop_interval_recurrence` WRITE;
|
||||
/*!40000 ALTER TABLE `shop_interval_recurrence` DISABLE KEYS */;
|
||||
INSERT INTO `shop_interval_recurrence` VALUES (1,'WEEK','Week','Weeks',_binary '','2024-04-28 19:03:07','root@localhost',NULL),(2,'MONTH','Month','Months',_binary '','2024-04-28 19:03:07','root@localhost',NULL),(3,'YEAR','Year','Years',_binary '','2024-04-28 19:03:07','root@localhost',NULL);
|
||||
/*!40000 ALTER TABLE `shop_interval_recurrence` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
|
||||
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
|
||||
@@ -3051,7 +3051,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_Recurrence_Interval` BEFORE INSERT ON `shop_recurrence_interval` FOR EACH ROW BEGIN
|
||||
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `before_insert_Shop_Interval_Recurrence` BEFORE INSERT ON `shop_interval_recurrence` FOR EACH ROW BEGIN
|
||||
SET NEW.created_on := IFNULL(NEW.created_on, NOW());
|
||||
SET NEW.created_by := IFNULL(NEW.created_by, IFNULL((SELECT id_user FROM Shop_User WHERE firstname = CURRENT_USER()), -1));
|
||||
END */;;
|
||||
@@ -3069,13 +3069,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_Recurrence_Interval` BEFORE UPDATE ON `shop_recurrence_interval` FOR EACH ROW BEGIN
|
||||
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `before_update_Shop_Interval_Recurrence` BEFORE UPDATE ON `shop_interval_recurrence` 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 (
|
||||
INSERT INTO Shop_Interval_Recurrence_Audit (
|
||||
id_interval,
|
||||
name_field,
|
||||
value_prev,
|
||||
@@ -3106,13 +3106,13 @@ DELIMITER ;;
|
||||
/*!50003 SET collation_connection = @saved_col_connection */ ;
|
||||
|
||||
--
|
||||
-- Table structure for table `shop_recurrence_interval_audit`
|
||||
-- Table structure for table `shop_interval_recurrence_audit`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `shop_recurrence_interval_audit`;
|
||||
DROP TABLE IF EXISTS `shop_interval_recurrence_audit`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!50503 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `shop_recurrence_interval_audit` (
|
||||
CREATE TABLE `shop_interval_recurrence_audit` (
|
||||
`id_audit` int NOT NULL AUTO_INCREMENT,
|
||||
`id_interval` int NOT NULL,
|
||||
`name_field` varchar(50) DEFAULT NULL,
|
||||
@@ -3120,20 +3120,20 @@ CREATE TABLE `shop_recurrence_interval_audit` (
|
||||
`value_new` varchar(256) DEFAULT NULL,
|
||||
`id_change_set` int NOT NULL,
|
||||
PRIMARY KEY (`id_audit`),
|
||||
KEY `FK_Shop_Recurrence_Interval_Audit_id_interval` (`id_interval`),
|
||||
KEY `FK_Shop_Recurrence_Interval_Audit_id_change_set` (`id_change_set`),
|
||||
CONSTRAINT `FK_Shop_Recurrence_Interval_Audit_id_change_set` FOREIGN KEY (`id_change_set`) REFERENCES `shop_product_change_set` (`id_change_set`),
|
||||
CONSTRAINT `FK_Shop_Recurrence_Interval_Audit_id_interval` FOREIGN KEY (`id_interval`) REFERENCES `shop_recurrence_interval` (`id_interval`) ON UPDATE RESTRICT
|
||||
KEY `FK_Shop_Interval_Recurrence_Audit_id_interval` (`id_interval`),
|
||||
KEY `FK_Shop_Interval_Recurrence_Audit_id_change_set` (`id_change_set`),
|
||||
CONSTRAINT `FK_Shop_Interval_Recurrence_Audit_id_change_set` FOREIGN KEY (`id_change_set`) REFERENCES `shop_product_change_set` (`id_change_set`),
|
||||
CONSTRAINT `FK_Shop_Interval_Recurrence_Audit_id_interval` FOREIGN KEY (`id_interval`) REFERENCES `shop_interval_recurrence` (`id_interval`) ON UPDATE RESTRICT
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `shop_recurrence_interval_audit`
|
||||
-- Dumping data for table `shop_interval_recurrence_audit`
|
||||
--
|
||||
|
||||
LOCK TABLES `shop_recurrence_interval_audit` WRITE;
|
||||
/*!40000 ALTER TABLE `shop_recurrence_interval_audit` DISABLE KEYS */;
|
||||
/*!40000 ALTER TABLE `shop_recurrence_interval_audit` ENABLE KEYS */;
|
||||
LOCK TABLES `shop_interval_recurrence_audit` WRITE;
|
||||
/*!40000 ALTER TABLE `shop_interval_recurrence_audit` DISABLE KEYS */;
|
||||
/*!40000 ALTER TABLE `shop_interval_recurrence_audit` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
@@ -6110,17 +6110,17 @@ BEGIN
|
||||
price_GBP_full FLOAT NOT NULL,
|
||||
price_GBP_min FLOAT NOT NULL,
|
||||
*/
|
||||
latency_manufacture INT NOT NULL,
|
||||
latency_manufacture_days INT NOT NULL,
|
||||
quantity_min FLOAT NOT NULL,
|
||||
quantity_max FLOAT NOT NULL,
|
||||
quantity_step FLOAT NOT NULL,
|
||||
quantity_stock FLOAT NOT NULL,
|
||||
is_subscription BIT NOT NULL,
|
||||
id_recurrence_interval INT,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_recurrence_interval
|
||||
FOREIGN KEY (id_recurrence_interval)
|
||||
REFERENCES Shop_Recurrence_Interval(id_interval),
|
||||
count_recurrence_interval INT,
|
||||
id_unit_measurement_interval_recurrence INT,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_unit_measurement_interval_recurrence
|
||||
FOREIGN KEY (id_unit_measurement_interval_recurrence)
|
||||
REFERENCES Shop_Interval_Recurrence(id_interval),
|
||||
count_interval_recurrence INT,
|
||||
id_stripe_product VARCHAR(100),
|
||||
product_has_variations INT NOT NULL,
|
||||
can_view BIT,
|
||||
@@ -6224,14 +6224,14 @@ BEGIN
|
||||
price_GBP_VAT_excl,
|
||||
price_GBP_min,
|
||||
*/
|
||||
latency_manufacture,
|
||||
latency_manufacture_days,
|
||||
quantity_min,
|
||||
quantity_max,
|
||||
quantity_step,
|
||||
quantity_stock,
|
||||
is_subscription,
|
||||
id_recurrence_interval,
|
||||
count_recurrence_interval,
|
||||
id_unit_measurement_interval_recurrence,
|
||||
count_interval_recurrence,
|
||||
id_stripe_product,
|
||||
product_has_variations
|
||||
)
|
||||
@@ -6254,14 +6254,14 @@ BEGIN
|
||||
PP.price_GBP_VAT_excl,
|
||||
PP.price_GBP_min,
|
||||
*/
|
||||
PP.latency_manufacture,
|
||||
PP.latency_manufacture_days,
|
||||
PP.quantity_min,
|
||||
PP.quantity_max,
|
||||
PP.quantity_step,
|
||||
PP.quantity_stock,
|
||||
PP.is_subscription,
|
||||
PP.id_recurrence_interval,
|
||||
PP.count_recurrence_interval,
|
||||
PP.id_unit_measurement_interval_recurrence,
|
||||
PP.count_interval_recurrence,
|
||||
PP.id_stripe_product,
|
||||
P.has_variations
|
||||
FROM Shop_Product P
|
||||
@@ -6705,16 +6705,16 @@ BEGIN
|
||||
t_P.description,
|
||||
P.has_variations,
|
||||
P.id_category,
|
||||
t_P.latency_manufacture,
|
||||
t_P.latency_manufacture_days,
|
||||
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,
|
||||
RI.name AS name_recurrence_interval,
|
||||
RI.name_plural AS name_plural_recurrence_interval,
|
||||
t_P.count_recurrence_interval,
|
||||
RI.name AS name_interval_recurrence,
|
||||
RI.name_plural AS name_plural_interval_recurrence,
|
||||
t_P.count_interval_recurrence,
|
||||
t_P.display_order_category,
|
||||
t_P.display_order_product,
|
||||
t_P.display_order_permutation,
|
||||
@@ -6724,8 +6724,8 @@ BEGIN
|
||||
FROM tmp_Shop_Product t_P
|
||||
INNER JOIN Shop_Product P
|
||||
ON t_P.id_product = P.id_product
|
||||
LEFT JOIN Shop_Recurrence_Interval RI
|
||||
ON t_P.id_recurrence_interval = RI.id_interval
|
||||
LEFT JOIN Shop_Interval_Recurrence RI
|
||||
ON t_P.id_unit_measurement_interval_recurrence = RI.id_interval
|
||||
ORDER BY t_P.rank_permutation
|
||||
;
|
||||
|
||||
@@ -7206,13 +7206,13 @@ BEGIN
|
||||
P.id_stripe_product,
|
||||
P.is_subscription,
|
||||
LOWER(RI.code) AS name_recurring_interval,
|
||||
P.count_recurrence_interval
|
||||
P.count_interval_recurrence
|
||||
FROM tmp_Shop_Product_Currency_Link t_PCL
|
||||
INNER JOIN Shop_Product P
|
||||
ON t_PCL.id_product = P.id_product
|
||||
AND P.active
|
||||
INNER JOIN Shop_Recurrence_Interval RI
|
||||
ON P.id_recurrence_interval = RI.id_interval
|
||||
INNER JOIN Shop_Interval_Recurrence RI
|
||||
ON P.id_unit_measurement_interval_recurrence = RI.id_interval
|
||||
AND RI.active
|
||||
INNER JOIN Shop_Currency C
|
||||
ON t_PCL.id_currency = C.id_currency
|
||||
|
||||
@@ -153,16 +153,19 @@
|
||||
3427_tri_Shop_Customer_Sales_Order_Product_Link.sql
|
||||
6000_p_split.sql
|
||||
6001_p_clear_split_temp.sql
|
||||
6206_fn_shop_get_product_permutation_name.sql
|
||||
6500_p_shop_user_eval.sql
|
||||
6501_p_clear_shop_user_eval_temp.sql
|
||||
7003_p_shop_get_many_access_level.sql
|
||||
7101_p_shop_get_many_region.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
|
||||
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
|
||||
7206_p_shop_save_product_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
|
||||
|
||||
@@ -157,8 +157,8 @@ DROP TABLE IF EXISTS Shop_Delivery_Region;
|
||||
DROP TABLE IF EXISTS Shop_Region_Audit;
|
||||
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_Interval_Recurrence_Audit;
|
||||
DROP TABLE IF EXISTS Shop_Interval_Recurrence;
|
||||
|
||||
DROP TABLE IF EXISTS Shop_Product_Category_Audit;
|
||||
DROP TABLE IF EXISTS Shop_Product_Category;
|
||||
@@ -503,9 +503,9 @@ CREATE TABLE IF NOT EXISTS Shop_Product_Category_Audit (
|
||||
|
||||
|
||||
|
||||
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Recurrence_Interval';
|
||||
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Interval_Recurrence';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS Shop_Recurrence_Interval (
|
||||
CREATE TABLE IF NOT EXISTS Shop_Interval_Recurrence (
|
||||
id_interval INTEGER NOT NULL PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
|
||||
code VARCHAR(50),
|
||||
name VARCHAR(255),
|
||||
@@ -514,7 +514,7 @@ CREATE TABLE IF NOT EXISTS Shop_Recurrence_Interval (
|
||||
created_on TIMESTAMP,
|
||||
created_by INT,
|
||||
id_change_set INTEGER,
|
||||
CONSTRAINT FK_Shop_Recurrence_Interval_id_change_set
|
||||
CONSTRAINT FK_Shop_Interval_Recurrence_id_change_set
|
||||
FOREIGN KEY (id_change_set)
|
||||
REFERENCES Shop_Product_Change_Set(id_change_set)
|
||||
);
|
||||
@@ -523,20 +523,20 @@ CREATE TABLE IF NOT EXISTS Shop_Recurrence_Interval (
|
||||
|
||||
|
||||
|
||||
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Recurrence_Interval_Audit';
|
||||
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Interval_Recurrence_Audit';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS Shop_Recurrence_Interval_Audit (
|
||||
CREATE TABLE IF NOT EXISTS Shop_Interval_Recurrence_Audit (
|
||||
id_audit INTEGER NOT NULL PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
|
||||
id_interval INTEGER NOT NULL,
|
||||
CONSTRAINT FK_Shop_Recurrence_Interval_Audit_id_interval
|
||||
CONSTRAINT FK_Shop_Interval_Recurrence_Audit_id_interval
|
||||
FOREIGN KEY (id_interval)
|
||||
REFERENCES Shop_Recurrence_Interval(id_interval)
|
||||
REFERENCES Shop_Interval_Recurrence(id_interval)
|
||||
ON UPDATE RESTRICT,
|
||||
name_field VARCHAR(50),
|
||||
value_prev VARCHAR(256),
|
||||
value_new VARCHAR(256),
|
||||
id_change_set INTEGER NOT NULL,
|
||||
CONSTRAINT FK_Shop_Recurrence_Interval_Audit_id_change_set
|
||||
CONSTRAINT FK_Shop_Interval_Recurrence_Audit_id_change_set
|
||||
FOREIGN KEY (id_change_set)
|
||||
REFERENCES Shop_Product_Change_Set(id_change_set)
|
||||
);
|
||||
@@ -760,11 +760,11 @@ CREATE TABLE IF NOT EXISTS Shop_Product (
|
||||
quantity_step REAL,
|
||||
quantity_stock REAL,
|
||||
is_subscription BOOLEAN,
|
||||
id_recurrence_interval INTEGER,
|
||||
CONSTRAINT FK_Shop_Product_id_recurrence_interval
|
||||
FOREIGN KEY (id_recurrence_interval)
|
||||
REFERENCES Shop_Recurrence_Interval(id_interval),
|
||||
count_recurrence_interval INTEGER,
|
||||
id_unit_measurement_interval_recurrence INTEGER,
|
||||
CONSTRAINT FK_Shop_Product_id_unit_measurement_interval_recurrence
|
||||
FOREIGN KEY (id_unit_measurement_interval_recurrence)
|
||||
REFERENCES Shop_Interval_Recurrence(id_interval),
|
||||
count_interval_recurrence INTEGER,
|
||||
*/
|
||||
id_access_level_required INTEGER NOT NULL,
|
||||
CONSTRAINT FK_Shop_Product_id_access_level_required
|
||||
@@ -911,17 +911,17 @@ CREATE TABLE IF NOT EXISTS Shop_Product_Permutation (
|
||||
id_currency_cost INTEGER NOT NULL,
|
||||
profit_local_min REAL NOT NULL,
|
||||
-- id_currency_profit_min INTEGER NOT NULL,
|
||||
latency_manufacture INTEGER NOT NULL,
|
||||
latency_manufacture_days INTEGER NOT NULL,
|
||||
quantity_min REAL NOT NULL,
|
||||
quantity_max REAL NOT NULL,
|
||||
quantity_step REAL NOT NULL,
|
||||
quantity_stock REAL NOT NULL,
|
||||
is_subscription BOOLEAN NOT NULL,
|
||||
id_recurrence_interval INTEGER,
|
||||
CONSTRAINT FK_Shop_Product_Permutation_id_recurrence_interval
|
||||
FOREIGN KEY (id_recurrence_interval)
|
||||
REFERENCES Shop_Recurrence_Interval(id_interval),
|
||||
count_recurrence_interval INTEGER,
|
||||
id_unit_measurement_interval_recurrence INTEGER,
|
||||
CONSTRAINT FK_Shop_Product_Permutation_id_unit_measurement_interval_recurrence
|
||||
FOREIGN KEY (id_unit_measurement_interval_recurrence)
|
||||
REFERENCES Shop_Interval_Recurrence(id_interval),
|
||||
count_interval_recurrence INTEGER,
|
||||
/*
|
||||
id_access_level_required INTEGER NOT NULL,
|
||||
CONSTRAINT FK_Shop_Product_Permutation_id_access_level_required
|
||||
@@ -2814,7 +2814,7 @@ EXECUTE FUNCTION before_update_Shop_Product_Category();
|
||||
|
||||
-- Shop Recurrence Interval
|
||||
|
||||
CREATE OR REPLACE FUNCTION before_insert_Shop_Recurrence_Interval()
|
||||
CREATE OR REPLACE FUNCTION before_insert_Shop_Interval_Recurrence()
|
||||
RETURNS TRIGGER AS $$
|
||||
BEGIN
|
||||
NEW.created_on = CURRENT_TIMESTAMP;
|
||||
@@ -2824,13 +2824,13 @@ BEGIN
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE OR REPLACE TRIGGER tri_before_insert_Shop_Recurrence_Interval
|
||||
BEFORE INSERT ON Shop_Recurrence_Interval
|
||||
CREATE OR REPLACE TRIGGER tri_before_insert_Shop_Interval_Recurrence
|
||||
BEFORE INSERT ON Shop_Interval_Recurrence
|
||||
FOR EACH ROW
|
||||
EXECUTE FUNCTION before_insert_Shop_Recurrence_Interval();
|
||||
EXECUTE FUNCTION before_insert_Shop_Interval_Recurrence();
|
||||
|
||||
|
||||
CREATE OR REPLACE FUNCTION before_update_Shop_Recurrence_Interval()
|
||||
CREATE OR REPLACE FUNCTION before_update_Shop_Interval_Recurrence()
|
||||
RETURNS TRIGGER AS $$
|
||||
BEGIN
|
||||
IF OLD.id_change_set IS NOT DISTINCT FROM NEW.id_change_set THEN
|
||||
@@ -2838,7 +2838,7 @@ BEGIN
|
||||
USING ERRCODE = '45000';
|
||||
END IF;
|
||||
|
||||
INSERT INTO Shop_Recurrence_Interval_Audit (
|
||||
INSERT INTO Shop_Interval_Recurrence_Audit (
|
||||
id_interval,
|
||||
name_field,
|
||||
value_prev,
|
||||
@@ -2866,10 +2866,10 @@ BEGIN
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE OR REPLACE TRIGGER tri_before_update_Shop_Recurrence_Interval
|
||||
BEFORE UPDATE ON Shop_Recurrence_Interval
|
||||
CREATE OR REPLACE TRIGGER tri_before_update_Shop_Interval_Recurrence
|
||||
BEFORE UPDATE ON Shop_Interval_Recurrence
|
||||
FOR EACH ROW
|
||||
EXECUTE FUNCTION before_update_Shop_Recurrence_Interval();
|
||||
EXECUTE FUNCTION before_update_Shop_Interval_Recurrence();
|
||||
|
||||
-- Shop Delivery Region
|
||||
|
||||
@@ -3197,11 +3197,11 @@ BEGIN
|
||||
SIGNAL SQLSTATE '45000'
|
||||
SET MESSAGE_TEXT = 'Product must have subscription status or variations (with subscription statuses).';
|
||||
END IF;
|
||||
IF ISNULL(NEW.id_recurrence_interval) THEN
|
||||
IF ISNULL(NEW.id_unit_measurement_interval_recurrence) THEN
|
||||
SIGNAL SQLSTATE '45000'
|
||||
SET MESSAGE_TEXT = 'Product must have recurrence interval or variations (with recurrence intervals).';
|
||||
END IF;
|
||||
IF ISNULL(NEW.count_recurrence_interval) THEN
|
||||
IF ISNULL(NEW.count_interval_recurrence) THEN
|
||||
SIGNAL SQLSTATE '45000'
|
||||
SET MESSAGE_TEXT = 'Product must have recurrence interval count or variations (with recurrence interval counts).';
|
||||
END IF;
|
||||
@@ -3271,13 +3271,13 @@ BEGIN
|
||||
SELECT NEW.id_product, 'is_subscription', CONVERT(CONVERT(OLD.is_subscription, SIGNED), CHAR), CONVERT(CONVERT(NEW.is_subscription, SIGNED), CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.is_subscription <=> NEW.is_subscription
|
||||
UNION
|
||||
-- Changed id_recurrence_interval
|
||||
SELECT NEW.id_product, 'id_recurrence_interval', CONVERT(OLD.id_recurrence_interval, CHAR), CONVERT(NEW.id_recurrence_interval, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.id_recurrence_interval <=> NEW.id_recurrence_interval
|
||||
-- Changed id_unit_measurement_interval_recurrence
|
||||
SELECT NEW.id_product, 'id_unit_measurement_interval_recurrence', CONVERT(OLD.id_unit_measurement_interval_recurrence, CHAR), CONVERT(NEW.id_unit_measurement_interval_recurrence, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.id_unit_measurement_interval_recurrence <=> NEW.id_unit_measurement_interval_recurrence
|
||||
UNION
|
||||
-- Changed count_recurrence_interval
|
||||
SELECT NEW.id_product, 'count_recurrence_interval', CONVERT(OLD.count_recurrence_interval, CHAR), CONVERT(NEW.count_recurrence_interval, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.count_recurrence_interval <=> NEW.count_recurrence_interval
|
||||
-- Changed count_interval_recurrence
|
||||
SELECT NEW.id_product, 'count_interval_recurrence', CONVERT(OLD.count_interval_recurrence, CHAR), CONVERT(NEW.count_interval_recurrence, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.count_interval_recurrence <=> NEW.count_interval_recurrence
|
||||
UNION
|
||||
-- Changed id_stripe_product
|
||||
SELECT NEW.id_product, 'id_stripe_product', OLD.id_stripe_product, NEW.id_stripe_product, NEW.id_change_set
|
||||
@@ -3512,9 +3512,9 @@ BEGIN
|
||||
WHERE NOT (OLD.price_GBP_min <=> NEW.price_GBP_min)
|
||||
UNION
|
||||
*/
|
||||
-- Changed latency_manufacture
|
||||
SELECT NEW.id_product, 'latency_manufacture', CONVERT(OLD.latency_manufacture, CHAR), CONVERT(NEW.latency_manufacture, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.latency_manufacture <=> NEW.latency_manufacture
|
||||
-- Changed latency_manufacture_days
|
||||
SELECT NEW.id_product, 'latency_manufacture_days', CONVERT(OLD.latency_manufacture_days, CHAR), CONVERT(NEW.latency_manufacture_days, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.latency_manufacture_days <=> NEW.latency_manufacture_days
|
||||
UNION
|
||||
-- Changed quantity_min
|
||||
SELECT NEW.id_product, 'quantity_min', CONVERT(OLD.quantity_min, CHAR), CONVERT(NEW.quantity_min, CHAR), NEW.id_change_set
|
||||
@@ -3536,13 +3536,13 @@ BEGIN
|
||||
SELECT NEW.id_product, 'is_subscription', CONVERT(CONVERT(OLD.is_subscription, SIGNED), CHAR), CONVERT(CONVERT(NEW.is_subscription, SIGNED), CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.is_subscription <=> NEW.is_subscription
|
||||
UNION
|
||||
-- Changed id_recurrence_interval
|
||||
SELECT NEW.id_product, 'id_recurrence_interval', CONVERT(OLD.id_recurrence_interval, CHAR), CONVERT(NEW.id_recurrence_interval, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.id_recurrence_interval <=> NEW.id_recurrence_interval
|
||||
-- Changed id_unit_measurement_interval_recurrence
|
||||
SELECT NEW.id_product, 'id_unit_measurement_interval_recurrence', CONVERT(OLD.id_unit_measurement_interval_recurrence, CHAR), CONVERT(NEW.id_unit_measurement_interval_recurrence, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.id_unit_measurement_interval_recurrence <=> NEW.id_unit_measurement_interval_recurrence
|
||||
UNION
|
||||
-- Changed count_recurrence_interval
|
||||
SELECT NEW.id_product, 'count_recurrence_interval', CONVERT(OLD.count_recurrence_interval, CHAR), CONVERT(NEW.count_recurrence_interval, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.count_recurrence_interval <=> NEW.count_recurrence_interval
|
||||
-- Changed count_interval_recurrence
|
||||
SELECT NEW.id_product, 'count_interval_recurrence', CONVERT(OLD.count_interval_recurrence, CHAR), CONVERT(NEW.count_interval_recurrence, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.count_interval_recurrence <=> NEW.count_interval_recurrence
|
||||
UNION
|
||||
-- Changed id_stripe_product
|
||||
SELECT NEW.id_permutation, 'id_stripe_product', OLD.id_stripe_product, NEW.id_stripe_product, NEW.id_change_set
|
||||
@@ -9749,19 +9749,19 @@ BEGIN
|
||||
price_GBP_full REAL NOT NULL,
|
||||
price_GBP_min REAL NOT NULL,
|
||||
*/
|
||||
latency_manufacture INTEGER NOT NULL,
|
||||
latency_manufacture_days INTEGER NOT NULL,
|
||||
quantity_min REAL NOT NULL,
|
||||
quantity_max REAL NOT NULL,
|
||||
quantity_step REAL NOT NULL,
|
||||
quantity_stock REAL NOT NULL,
|
||||
is_subscription BOOLEAN NOT NULL,
|
||||
id_recurrence_interval INTEGER,
|
||||
id_unit_measurement_interval_recurrence INTEGER,
|
||||
/*
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_recurrence_interval
|
||||
FOREIGN KEY (id_recurrence_interval)
|
||||
REFERENCES Shop_Recurrence_Interval(id_interval),
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_unit_measurement_interval_recurrence
|
||||
FOREIGN KEY (id_unit_measurement_interval_recurrence)
|
||||
REFERENCES Shop_Interval_Recurrence(id_interval),
|
||||
*/
|
||||
count_recurrence_interval INTEGER,
|
||||
count_interval_recurrence INTEGER,
|
||||
id_stripe_product VARCHAR(100),
|
||||
product_has_variations BOOLEAN NOT NULL,
|
||||
can_view BOOLEAN,
|
||||
@@ -9872,14 +9872,14 @@ BEGIN
|
||||
price_GBP_VAT_excl,
|
||||
price_GBP_min,
|
||||
*/
|
||||
latency_manufacture,
|
||||
latency_manufacture_days,
|
||||
quantity_min,
|
||||
quantity_max,
|
||||
quantity_step,
|
||||
quantity_stock,
|
||||
is_subscription,
|
||||
id_recurrence_interval,
|
||||
count_recurrence_interval,
|
||||
id_unit_measurement_interval_recurrence,
|
||||
count_interval_recurrence,
|
||||
id_stripe_product,
|
||||
product_has_variations
|
||||
)
|
||||
@@ -9905,14 +9905,14 @@ BEGIN
|
||||
PP.price_GBP_VAT_excl,
|
||||
PP.price_GBP_min,
|
||||
*/
|
||||
PP.latency_manufacture,
|
||||
PP.latency_manufacture_days,
|
||||
PP.quantity_min,
|
||||
PP.quantity_max,
|
||||
PP.quantity_step,
|
||||
PP.quantity_stock,
|
||||
PP.is_subscription,
|
||||
PP.id_recurrence_interval,
|
||||
PP.count_recurrence_interval,
|
||||
PP.id_unit_measurement_interval_recurrence,
|
||||
PP.count_interval_recurrence,
|
||||
PP.id_stripe_product,
|
||||
P.has_variations
|
||||
FROM Shop_Product P
|
||||
@@ -10412,16 +10412,16 @@ BEGIN
|
||||
PP.cost_local,
|
||||
PP.id_currency_cost,
|
||||
PP.profit_local_min,
|
||||
t_P.latency_manufacture,
|
||||
t_P.latency_manufacture_days,
|
||||
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,
|
||||
RI.name AS name_recurrence_interval,
|
||||
RI.name_plural AS name_plural_recurrence_interval,
|
||||
t_P.count_recurrence_interval,
|
||||
RI.name AS name_interval_recurrence,
|
||||
RI.name_plural AS name_plural_interval_recurrence,
|
||||
t_P.count_interval_recurrence,
|
||||
t_P.display_order_category,
|
||||
t_P.display_order_product,
|
||||
t_P.display_order_permutation,
|
||||
@@ -10431,7 +10431,7 @@ BEGIN
|
||||
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_recurrence_interval = RI.id_interval
|
||||
LEFT JOIN Shop_Interval_Recurrence RI ON t_P.id_unit_measurement_interval_recurrence = RI.id_interval
|
||||
ORDER BY t_P.rank_permutation
|
||||
;
|
||||
RETURN NEXT result_products;
|
||||
@@ -11663,13 +11663,13 @@ BEGIN
|
||||
P.id_stripe_product,
|
||||
P.is_subscription,
|
||||
LOWER(RI.code) AS name_recurring_interval,
|
||||
P.count_recurrence_interval
|
||||
P.count_interval_recurrence
|
||||
FROM tmp_Shop_Product_Currency_Link t_PCL
|
||||
INNER JOIN Shop_Product P
|
||||
ON t_PCL.id_product = P.id_product
|
||||
AND P.active
|
||||
INNER JOIN Shop_Recurrence_Interval RI
|
||||
ON P.id_recurrence_interval = RI.id_interval
|
||||
INNER JOIN Shop_Interval_Recurrence RI
|
||||
ON P.id_unit_measurement_interval_recurrence = RI.id_interval
|
||||
AND RI.active
|
||||
INNER JOIN Shop_Currency C
|
||||
ON t_PCL.id_currency = C.id_currency
|
||||
@@ -12162,17 +12162,17 @@ BEGIN
|
||||
price_GBP_full REAL NOT NULL,
|
||||
price_GBP_min REAL NOT NULL,
|
||||
*/
|
||||
latency_manufacture INTEGER NOT NULL,
|
||||
latency_manufacture_days INTEGER NOT NULL,
|
||||
quantity_min REAL NOT NULL,
|
||||
quantity_max REAL NOT NULL,
|
||||
quantity_step REAL NOT NULL,
|
||||
quantity_stock REAL NOT NULL,
|
||||
is_subscription BOOLEAN NOT NULL,
|
||||
id_recurrence_interval INTEGER,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_recurrence_interval
|
||||
FOREIGN KEY (id_recurrence_interval)
|
||||
REFERENCES Shop_Recurrence_Interval(id_interval),
|
||||
count_recurrence_interval INTEGER,
|
||||
id_unit_measurement_interval_recurrence INTEGER,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_unit_measurement_interval_recurrence
|
||||
FOREIGN KEY (id_unit_measurement_interval_recurrence)
|
||||
REFERENCES Shop_Interval_Recurrence(id_interval),
|
||||
count_interval_recurrence INTEGER,
|
||||
id_stripe_product VARCHAR(100),
|
||||
product_has_variations INTEGER NOT NULL,
|
||||
can_view BOOLEAN,
|
||||
@@ -12318,14 +12318,14 @@ BEGIN
|
||||
price_GBP_VAT_excl,
|
||||
price_GBP_min,
|
||||
*/
|
||||
latency_manufacture,
|
||||
latency_manufacture_days,
|
||||
quantity_min,
|
||||
quantity_max,
|
||||
quantity_step,
|
||||
quantity_stock,
|
||||
is_subscription,
|
||||
id_recurrence_interval,
|
||||
count_recurrence_interval,
|
||||
id_unit_measurement_interval_recurrence,
|
||||
count_interval_recurrence,
|
||||
id_stripe_product,
|
||||
product_has_variations
|
||||
*/
|
||||
@@ -12350,14 +12350,14 @@ BEGIN
|
||||
PP.price_GBP_VAT_excl,
|
||||
PP.price_GBP_min,
|
||||
*/
|
||||
PP.latency_manufacture,
|
||||
PP.latency_manufacture_days,
|
||||
PP.quantity_min,
|
||||
PP.quantity_max,
|
||||
PP.quantity_step,
|
||||
PP.quantity_stock,
|
||||
PP.is_subscription,
|
||||
PP.id_recurrence_interval,
|
||||
PP.count_recurrence_interval,
|
||||
PP.id_unit_measurement_interval_recurrence,
|
||||
PP.count_interval_recurrence,
|
||||
PP.id_stripe_product,
|
||||
P.has_variations
|
||||
*/
|
||||
@@ -12849,17 +12849,17 @@ BEGIN
|
||||
price_GBP_min REAL NOT NULL,
|
||||
*/
|
||||
/*
|
||||
latency_manufacture INTEGER NOT NULL,
|
||||
latency_manufacture_days INTEGER NOT NULL,
|
||||
quantity_min REAL NOT NULL,
|
||||
quantity_max REAL NOT NULL,
|
||||
quantity_step REAL NOT NULL,
|
||||
quantity_stock REAL NOT NULL,
|
||||
is_subscription BOOLEAN NOT NULL,
|
||||
id_recurrence_interval INTEGER,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_recurrence_interval
|
||||
FOREIGN KEY (id_recurrence_interval)
|
||||
REFERENCES Shop_Recurrence_Interval(id_interval),
|
||||
count_recurrence_interval INTEGER,
|
||||
id_unit_measurement_interval_recurrence INTEGER,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_unit_measurement_interval_recurrence
|
||||
FOREIGN KEY (id_unit_measurement_interval_recurrence)
|
||||
REFERENCES Shop_Interval_Recurrence(id_interval),
|
||||
count_interval_recurrence INTEGER,
|
||||
id_stripe_product VARCHAR(100),
|
||||
product_has_variations INTEGER NOT NULL,
|
||||
*/
|
||||
@@ -12953,14 +12953,14 @@ BEGIN
|
||||
price_GBP_VAT_excl,
|
||||
price_GBP_min,
|
||||
*/
|
||||
latency_manufacture,
|
||||
latency_manufacture_days,
|
||||
quantity_min,
|
||||
quantity_max,
|
||||
quantity_step,
|
||||
quantity_stock,
|
||||
is_subscription,
|
||||
id_recurrence_interval,
|
||||
count_recurrence_interval,
|
||||
id_unit_measurement_interval_recurrence,
|
||||
count_interval_recurrence,
|
||||
id_stripe_product,
|
||||
product_has_variations
|
||||
*/
|
||||
@@ -12985,14 +12985,14 @@ BEGIN
|
||||
PP.price_GBP_VAT_excl,
|
||||
PP.price_GBP_min,
|
||||
*/
|
||||
PP.latency_manufacture,
|
||||
PP.latency_manufacture_days,
|
||||
PP.quantity_min,
|
||||
PP.quantity_max,
|
||||
PP.quantity_step,
|
||||
PP.quantity_stock,
|
||||
PP.is_subscription,
|
||||
PP.id_recurrence_interval,
|
||||
PP.count_recurrence_interval,
|
||||
PP.id_unit_measurement_interval_recurrence,
|
||||
PP.count_interval_recurrence,
|
||||
PP.id_stripe_product,
|
||||
P.has_variations
|
||||
*/
|
||||
@@ -13731,17 +13731,17 @@ BEGIN
|
||||
price_GBP_min REAL NOT NULL,
|
||||
*/
|
||||
/*
|
||||
latency_manufacture INTEGER NOT NULL,
|
||||
latency_manufacture_days INTEGER NOT NULL,
|
||||
quantity_min REAL NOT NULL,
|
||||
quantity_max REAL NOT NULL,
|
||||
quantity_step REAL NOT NULL,
|
||||
quantity_stock REAL NOT NULL,
|
||||
is_subscription BOOLEAN NOT NULL,
|
||||
id_recurrence_interval INTEGER,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_recurrence_interval
|
||||
FOREIGN KEY (id_recurrence_interval)
|
||||
REFERENCES Shop_Recurrence_Interval(id_interval),
|
||||
count_recurrence_interval INTEGER,
|
||||
id_unit_measurement_interval_recurrence INTEGER,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_unit_measurement_interval_recurrence
|
||||
FOREIGN KEY (id_unit_measurement_interval_recurrence)
|
||||
REFERENCES Shop_Interval_Recurrence(id_interval),
|
||||
count_interval_recurrence INTEGER,
|
||||
id_stripe_product VARCHAR(100),
|
||||
product_has_variations INTEGER NOT NULL,
|
||||
*/
|
||||
@@ -13887,14 +13887,14 @@ BEGIN
|
||||
price_GBP_VAT_excl,
|
||||
price_GBP_min,
|
||||
*/
|
||||
latency_manufacture,
|
||||
latency_manufacture_days,
|
||||
quantity_min,
|
||||
quantity_max,
|
||||
quantity_step,
|
||||
quantity_stock,
|
||||
is_subscription,
|
||||
id_recurrence_interval,
|
||||
count_recurrence_interval,
|
||||
id_unit_measurement_interval_recurrence,
|
||||
count_interval_recurrence,
|
||||
id_stripe_product,
|
||||
product_has_variations
|
||||
*/
|
||||
@@ -13919,14 +13919,14 @@ BEGIN
|
||||
PP.price_GBP_VAT_excl,
|
||||
PP.price_GBP_min,
|
||||
*/
|
||||
PP.latency_manufacture,
|
||||
PP.latency_manufacture_days,
|
||||
PP.quantity_min,
|
||||
PP.quantity_max,
|
||||
PP.quantity_step,
|
||||
PP.quantity_stock,
|
||||
PP.is_subscription,
|
||||
PP.id_recurrence_interval,
|
||||
PP.count_recurrence_interval,
|
||||
PP.id_unit_measurement_interval_recurrence,
|
||||
PP.count_interval_recurrence,
|
||||
PP.id_stripe_product,
|
||||
P.has_variations
|
||||
*/
|
||||
@@ -14345,7 +14345,7 @@ VALUES
|
||||
;
|
||||
|
||||
-- Recurrence Interval
|
||||
INSERT INTO Shop_Recurrence_Interval (
|
||||
INSERT INTO Shop_Interval_Recurrence (
|
||||
code, name, name_plural
|
||||
)
|
||||
VALUES
|
||||
@@ -14468,14 +14468,14 @@ INSERT INTO Shop_Product_Permutation (
|
||||
id_currency_cost,
|
||||
profit_local_min,
|
||||
-- id_currency_profit_min,
|
||||
latency_manufacture,
|
||||
latency_manufacture_days,
|
||||
quantity_min,
|
||||
quantity_max,
|
||||
quantity_step,
|
||||
quantity_stock,
|
||||
is_subscription,
|
||||
id_recurrence_interval,
|
||||
count_recurrence_interval,
|
||||
id_unit_measurement_interval_recurrence,
|
||||
count_interval_recurrence,
|
||||
-- id_access_level_required,
|
||||
id_stripe_product
|
||||
)
|
||||
@@ -14956,8 +14956,8 @@ SELECT * FROM Shop_Product_Category;
|
||||
SELECT * FROM Shop_Product_Category_Audit;
|
||||
|
||||
-- Recurrence Interval
|
||||
SELECT * FROM Shop_Recurrence_Interval;
|
||||
SELECT * FROM Shop_Recurrence_Interval_Audit;
|
||||
SELECT * FROM Shop_Interval_Recurrence;
|
||||
SELECT * FROM Shop_Interval_Recurrence_Audit;
|
||||
|
||||
-- Region
|
||||
SELECT * FROM Shop_Region;
|
||||
|
||||
@@ -157,8 +157,8 @@ DROP TABLE IF EXISTS Shop_Delivery_Region;
|
||||
DROP TABLE IF EXISTS Shop_Region_Audit;
|
||||
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_Interval_Recurrence_Audit;
|
||||
DROP TABLE IF EXISTS Shop_Interval_Recurrence;
|
||||
|
||||
DROP TABLE IF EXISTS Shop_Product_Category_Audit;
|
||||
DROP TABLE IF EXISTS Shop_Product_Category;
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
|
||||
|
||||
|
||||
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Recurrence_Interval';
|
||||
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Interval_Recurrence';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS Shop_Recurrence_Interval (
|
||||
CREATE TABLE IF NOT EXISTS Shop_Interval_Recurrence (
|
||||
id_interval INTEGER NOT NULL PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
|
||||
code VARCHAR(50),
|
||||
name VARCHAR(255),
|
||||
@@ -14,7 +14,7 @@ CREATE TABLE IF NOT EXISTS Shop_Recurrence_Interval (
|
||||
created_on TIMESTAMP,
|
||||
created_by INT,
|
||||
id_change_set INTEGER,
|
||||
CONSTRAINT FK_Shop_Recurrence_Interval_id_change_set
|
||||
CONSTRAINT FK_Shop_Interval_Recurrence_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_Recurrence_Interval_Audit';
|
||||
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Interval_Recurrence_Audit';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS Shop_Recurrence_Interval_Audit (
|
||||
CREATE TABLE IF NOT EXISTS Shop_Interval_Recurrence_Audit (
|
||||
id_audit INTEGER NOT NULL PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
|
||||
id_interval INTEGER NOT NULL,
|
||||
CONSTRAINT FK_Shop_Recurrence_Interval_Audit_id_interval
|
||||
CONSTRAINT FK_Shop_Interval_Recurrence_Audit_id_interval
|
||||
FOREIGN KEY (id_interval)
|
||||
REFERENCES Shop_Recurrence_Interval(id_interval)
|
||||
REFERENCES Shop_Interval_Recurrence(id_interval)
|
||||
ON UPDATE RESTRICT,
|
||||
name_field VARCHAR(50),
|
||||
value_prev VARCHAR(256),
|
||||
value_new VARCHAR(256),
|
||||
id_change_set INTEGER NOT NULL,
|
||||
CONSTRAINT FK_Shop_Recurrence_Interval_Audit_id_change_set
|
||||
CONSTRAINT FK_Shop_Interval_Recurrence_Audit_id_change_set
|
||||
FOREIGN KEY (id_change_set)
|
||||
REFERENCES Shop_Product_Change_Set(id_change_set)
|
||||
);
|
||||
|
||||
@@ -25,11 +25,11 @@ CREATE TABLE IF NOT EXISTS Shop_Product (
|
||||
quantity_step REAL,
|
||||
quantity_stock REAL,
|
||||
is_subscription BOOLEAN,
|
||||
id_recurrence_interval INTEGER,
|
||||
CONSTRAINT FK_Shop_Product_id_recurrence_interval
|
||||
FOREIGN KEY (id_recurrence_interval)
|
||||
REFERENCES Shop_Recurrence_Interval(id_interval),
|
||||
count_recurrence_interval INTEGER,
|
||||
id_unit_measurement_interval_recurrence INTEGER,
|
||||
CONSTRAINT FK_Shop_Product_id_unit_measurement_interval_recurrence
|
||||
FOREIGN KEY (id_unit_measurement_interval_recurrence)
|
||||
REFERENCES Shop_Interval_Recurrence(id_interval),
|
||||
count_interval_recurrence INTEGER,
|
||||
*/
|
||||
id_access_level_required INTEGER NOT NULL,
|
||||
CONSTRAINT FK_Shop_Product_id_access_level_required
|
||||
|
||||
@@ -18,17 +18,17 @@ CREATE TABLE IF NOT EXISTS Shop_Product_Permutation (
|
||||
id_currency_cost INTEGER NOT NULL,
|
||||
profit_local_min REAL NOT NULL,
|
||||
-- id_currency_profit_min INTEGER NOT NULL,
|
||||
latency_manufacture INTEGER NOT NULL,
|
||||
latency_manufacture_days INTEGER NOT NULL,
|
||||
quantity_min REAL NOT NULL,
|
||||
quantity_max REAL NOT NULL,
|
||||
quantity_step REAL NOT NULL,
|
||||
quantity_stock REAL NOT NULL,
|
||||
is_subscription BOOLEAN NOT NULL,
|
||||
id_recurrence_interval INTEGER,
|
||||
CONSTRAINT FK_Shop_Product_Permutation_id_recurrence_interval
|
||||
FOREIGN KEY (id_recurrence_interval)
|
||||
REFERENCES Shop_Recurrence_Interval(id_interval),
|
||||
count_recurrence_interval INTEGER,
|
||||
id_unit_measurement_interval_recurrence INTEGER,
|
||||
CONSTRAINT FK_Shop_Product_Permutation_id_unit_measurement_interval_recurrence
|
||||
FOREIGN KEY (id_unit_measurement_interval_recurrence)
|
||||
REFERENCES Shop_Interval_Recurrence(id_interval),
|
||||
count_interval_recurrence INTEGER,
|
||||
/*
|
||||
id_access_level_required INTEGER NOT NULL,
|
||||
CONSTRAINT FK_Shop_Product_Permutation_id_access_level_required
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
-- Shop Recurrence Interval
|
||||
|
||||
CREATE OR REPLACE FUNCTION before_insert_Shop_Recurrence_Interval()
|
||||
CREATE OR REPLACE FUNCTION before_insert_Shop_Interval_Recurrence()
|
||||
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_Recurrence_Interval
|
||||
BEFORE INSERT ON Shop_Recurrence_Interval
|
||||
CREATE OR REPLACE TRIGGER tri_before_insert_Shop_Interval_Recurrence
|
||||
BEFORE INSERT ON Shop_Interval_Recurrence
|
||||
FOR EACH ROW
|
||||
EXECUTE FUNCTION before_insert_Shop_Recurrence_Interval();
|
||||
EXECUTE FUNCTION before_insert_Shop_Interval_Recurrence();
|
||||
|
||||
|
||||
CREATE OR REPLACE FUNCTION before_update_Shop_Recurrence_Interval()
|
||||
CREATE OR REPLACE FUNCTION before_update_Shop_Interval_Recurrence()
|
||||
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_Recurrence_Interval_Audit (
|
||||
INSERT INTO Shop_Interval_Recurrence_Audit (
|
||||
id_interval,
|
||||
name_field,
|
||||
value_prev,
|
||||
@@ -53,7 +53,7 @@ BEGIN
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE OR REPLACE TRIGGER tri_before_update_Shop_Recurrence_Interval
|
||||
BEFORE UPDATE ON Shop_Recurrence_Interval
|
||||
CREATE OR REPLACE TRIGGER tri_before_update_Shop_Interval_Recurrence
|
||||
BEFORE UPDATE ON Shop_Interval_Recurrence
|
||||
FOR EACH ROW
|
||||
EXECUTE FUNCTION before_update_Shop_Recurrence_Interval();
|
||||
EXECUTE FUNCTION before_update_Shop_Interval_Recurrence();
|
||||
|
||||
@@ -58,11 +58,11 @@ BEGIN
|
||||
SIGNAL SQLSTATE '45000'
|
||||
SET MESSAGE_TEXT = 'Product must have subscription status or variations (with subscription statuses).';
|
||||
END IF;
|
||||
IF ISNULL(NEW.id_recurrence_interval) THEN
|
||||
IF ISNULL(NEW.id_unit_measurement_interval_recurrence) THEN
|
||||
SIGNAL SQLSTATE '45000'
|
||||
SET MESSAGE_TEXT = 'Product must have recurrence interval or variations (with recurrence intervals).';
|
||||
END IF;
|
||||
IF ISNULL(NEW.count_recurrence_interval) THEN
|
||||
IF ISNULL(NEW.count_interval_recurrence) THEN
|
||||
SIGNAL SQLSTATE '45000'
|
||||
SET MESSAGE_TEXT = 'Product must have recurrence interval count or variations (with recurrence interval counts).';
|
||||
END IF;
|
||||
@@ -132,13 +132,13 @@ BEGIN
|
||||
SELECT NEW.id_product, 'is_subscription', CONVERT(CONVERT(OLD.is_subscription, SIGNED), CHAR), CONVERT(CONVERT(NEW.is_subscription, SIGNED), CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.is_subscription <=> NEW.is_subscription
|
||||
UNION
|
||||
-- Changed id_recurrence_interval
|
||||
SELECT NEW.id_product, 'id_recurrence_interval', CONVERT(OLD.id_recurrence_interval, CHAR), CONVERT(NEW.id_recurrence_interval, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.id_recurrence_interval <=> NEW.id_recurrence_interval
|
||||
-- Changed id_unit_measurement_interval_recurrence
|
||||
SELECT NEW.id_product, 'id_unit_measurement_interval_recurrence', CONVERT(OLD.id_unit_measurement_interval_recurrence, CHAR), CONVERT(NEW.id_unit_measurement_interval_recurrence, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.id_unit_measurement_interval_recurrence <=> NEW.id_unit_measurement_interval_recurrence
|
||||
UNION
|
||||
-- Changed count_recurrence_interval
|
||||
SELECT NEW.id_product, 'count_recurrence_interval', CONVERT(OLD.count_recurrence_interval, CHAR), CONVERT(NEW.count_recurrence_interval, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.count_recurrence_interval <=> NEW.count_recurrence_interval
|
||||
-- Changed count_interval_recurrence
|
||||
SELECT NEW.id_product, 'count_interval_recurrence', CONVERT(OLD.count_interval_recurrence, CHAR), CONVERT(NEW.count_interval_recurrence, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.count_interval_recurrence <=> NEW.count_interval_recurrence
|
||||
UNION
|
||||
-- Changed id_stripe_product
|
||||
SELECT NEW.id_product, 'id_stripe_product', OLD.id_stripe_product, NEW.id_stripe_product, NEW.id_change_set
|
||||
|
||||
@@ -78,9 +78,9 @@ BEGIN
|
||||
WHERE NOT (OLD.price_GBP_min <=> NEW.price_GBP_min)
|
||||
UNION
|
||||
*/
|
||||
-- Changed latency_manufacture
|
||||
SELECT NEW.id_product, 'latency_manufacture', CONVERT(OLD.latency_manufacture, CHAR), CONVERT(NEW.latency_manufacture, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.latency_manufacture <=> NEW.latency_manufacture
|
||||
-- Changed latency_manufacture_days
|
||||
SELECT NEW.id_product, 'latency_manufacture_days', CONVERT(OLD.latency_manufacture_days, CHAR), CONVERT(NEW.latency_manufacture_days, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.latency_manufacture_days <=> NEW.latency_manufacture_days
|
||||
UNION
|
||||
-- Changed quantity_min
|
||||
SELECT NEW.id_product, 'quantity_min', CONVERT(OLD.quantity_min, CHAR), CONVERT(NEW.quantity_min, CHAR), NEW.id_change_set
|
||||
@@ -102,13 +102,13 @@ BEGIN
|
||||
SELECT NEW.id_product, 'is_subscription', CONVERT(CONVERT(OLD.is_subscription, SIGNED), CHAR), CONVERT(CONVERT(NEW.is_subscription, SIGNED), CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.is_subscription <=> NEW.is_subscription
|
||||
UNION
|
||||
-- Changed id_recurrence_interval
|
||||
SELECT NEW.id_product, 'id_recurrence_interval', CONVERT(OLD.id_recurrence_interval, CHAR), CONVERT(NEW.id_recurrence_interval, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.id_recurrence_interval <=> NEW.id_recurrence_interval
|
||||
-- Changed id_unit_measurement_interval_recurrence
|
||||
SELECT NEW.id_product, 'id_unit_measurement_interval_recurrence', CONVERT(OLD.id_unit_measurement_interval_recurrence, CHAR), CONVERT(NEW.id_unit_measurement_interval_recurrence, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.id_unit_measurement_interval_recurrence <=> NEW.id_unit_measurement_interval_recurrence
|
||||
UNION
|
||||
-- Changed count_recurrence_interval
|
||||
SELECT NEW.id_product, 'count_recurrence_interval', CONVERT(OLD.count_recurrence_interval, CHAR), CONVERT(NEW.count_recurrence_interval, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.count_recurrence_interval <=> NEW.count_recurrence_interval
|
||||
-- Changed count_interval_recurrence
|
||||
SELECT NEW.id_product, 'count_interval_recurrence', CONVERT(OLD.count_interval_recurrence, CHAR), CONVERT(NEW.count_interval_recurrence, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.count_interval_recurrence <=> NEW.count_interval_recurrence
|
||||
UNION
|
||||
-- Changed id_stripe_product
|
||||
SELECT NEW.id_permutation, 'id_stripe_product', OLD.id_stripe_product, NEW.id_stripe_product, NEW.id_change_set
|
||||
|
||||
@@ -211,17 +211,17 @@ BEGIN
|
||||
P.id_stripe_product,
|
||||
P.id_stripe_price,
|
||||
P.is_subscription,
|
||||
RI.name AS name_recurrence_interval,
|
||||
RI.name_plural AS name_plural_recurrence_interval,
|
||||
P.count_recurrence_interval,
|
||||
RI.name AS name_interval_recurrence,
|
||||
RI.name_plural AS name_plural_interval_recurrence,
|
||||
P.count_interval_recurrence,
|
||||
tP.can_view,
|
||||
tP.can_edit,
|
||||
tP.can_admin
|
||||
FROM tmp_Shop_Product tP
|
||||
INNER JOIN Shop_Product P
|
||||
ON tP.id_product = P.id_product
|
||||
INNER JOIN Shop_Recurrence_Interval RI
|
||||
ON P.id_recurrence_interval = RI.id_interval
|
||||
INNER JOIN Shop_Interval_Recurrence RI
|
||||
ON P.id_unit_measurement_interval_recurrence = RI.id_interval
|
||||
;
|
||||
|
||||
-- Variations
|
||||
|
||||
@@ -203,19 +203,19 @@ BEGIN
|
||||
price_GBP_full REAL NOT NULL,
|
||||
price_GBP_min REAL NOT NULL,
|
||||
*/
|
||||
latency_manufacture INTEGER NOT NULL,
|
||||
latency_manufacture_days INTEGER NOT NULL,
|
||||
quantity_min REAL NOT NULL,
|
||||
quantity_max REAL NOT NULL,
|
||||
quantity_step REAL NOT NULL,
|
||||
quantity_stock REAL NOT NULL,
|
||||
is_subscription BOOLEAN NOT NULL,
|
||||
id_recurrence_interval INTEGER,
|
||||
id_unit_measurement_interval_recurrence INTEGER,
|
||||
/*
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_recurrence_interval
|
||||
FOREIGN KEY (id_recurrence_interval)
|
||||
REFERENCES Shop_Recurrence_Interval(id_interval),
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_unit_measurement_interval_recurrence
|
||||
FOREIGN KEY (id_unit_measurement_interval_recurrence)
|
||||
REFERENCES Shop_Interval_Recurrence(id_interval),
|
||||
*/
|
||||
count_recurrence_interval INTEGER,
|
||||
count_interval_recurrence INTEGER,
|
||||
id_stripe_product VARCHAR(100),
|
||||
product_has_variations BOOLEAN NOT NULL,
|
||||
can_view BOOLEAN,
|
||||
@@ -326,14 +326,14 @@ BEGIN
|
||||
price_GBP_VAT_excl,
|
||||
price_GBP_min,
|
||||
*/
|
||||
latency_manufacture,
|
||||
latency_manufacture_days,
|
||||
quantity_min,
|
||||
quantity_max,
|
||||
quantity_step,
|
||||
quantity_stock,
|
||||
is_subscription,
|
||||
id_recurrence_interval,
|
||||
count_recurrence_interval,
|
||||
id_unit_measurement_interval_recurrence,
|
||||
count_interval_recurrence,
|
||||
id_stripe_product,
|
||||
product_has_variations
|
||||
)
|
||||
@@ -359,14 +359,14 @@ BEGIN
|
||||
PP.price_GBP_VAT_excl,
|
||||
PP.price_GBP_min,
|
||||
*/
|
||||
PP.latency_manufacture,
|
||||
PP.latency_manufacture_days,
|
||||
PP.quantity_min,
|
||||
PP.quantity_max,
|
||||
PP.quantity_step,
|
||||
PP.quantity_stock,
|
||||
PP.is_subscription,
|
||||
PP.id_recurrence_interval,
|
||||
PP.count_recurrence_interval,
|
||||
PP.id_unit_measurement_interval_recurrence,
|
||||
PP.count_interval_recurrence,
|
||||
PP.id_stripe_product,
|
||||
P.has_variations
|
||||
FROM Shop_Product P
|
||||
@@ -866,16 +866,16 @@ BEGIN
|
||||
PP.cost_local,
|
||||
PP.id_currency_cost,
|
||||
PP.profit_local_min,
|
||||
t_P.latency_manufacture,
|
||||
t_P.latency_manufacture_days,
|
||||
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,
|
||||
RI.name AS name_recurrence_interval,
|
||||
RI.name_plural AS name_plural_recurrence_interval,
|
||||
t_P.count_recurrence_interval,
|
||||
RI.name AS name_interval_recurrence,
|
||||
RI.name_plural AS name_plural_interval_recurrence,
|
||||
t_P.count_interval_recurrence,
|
||||
t_P.display_order_category,
|
||||
t_P.display_order_product,
|
||||
t_P.display_order_permutation,
|
||||
@@ -885,7 +885,7 @@ BEGIN
|
||||
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_recurrence_interval = RI.id_interval
|
||||
LEFT JOIN Shop_Interval_Recurrence RI ON t_P.id_unit_measurement_interval_recurrence = RI.id_interval
|
||||
ORDER BY t_P.rank_permutation
|
||||
;
|
||||
RETURN NEXT result_products;
|
||||
|
||||
@@ -170,13 +170,13 @@ BEGIN
|
||||
P.id_stripe_product,
|
||||
P.is_subscription,
|
||||
LOWER(RI.code) AS name_recurring_interval,
|
||||
P.count_recurrence_interval
|
||||
P.count_interval_recurrence
|
||||
FROM tmp_Shop_Product_Currency_Link t_PCL
|
||||
INNER JOIN Shop_Product P
|
||||
ON t_PCL.id_product = P.id_product
|
||||
AND P.active
|
||||
INNER JOIN Shop_Recurrence_Interval RI
|
||||
ON P.id_recurrence_interval = RI.id_interval
|
||||
INNER JOIN Shop_Interval_Recurrence RI
|
||||
ON P.id_unit_measurement_interval_recurrence = RI.id_interval
|
||||
AND RI.active
|
||||
INNER JOIN Shop_Currency C
|
||||
ON t_PCL.id_currency = C.id_currency
|
||||
|
||||
@@ -169,17 +169,17 @@ BEGIN
|
||||
price_GBP_full REAL NOT NULL,
|
||||
price_GBP_min REAL NOT NULL,
|
||||
*/
|
||||
latency_manufacture INTEGER NOT NULL,
|
||||
latency_manufacture_days INTEGER NOT NULL,
|
||||
quantity_min REAL NOT NULL,
|
||||
quantity_max REAL NOT NULL,
|
||||
quantity_step REAL NOT NULL,
|
||||
quantity_stock REAL NOT NULL,
|
||||
is_subscription BOOLEAN NOT NULL,
|
||||
id_recurrence_interval INTEGER,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_recurrence_interval
|
||||
FOREIGN KEY (id_recurrence_interval)
|
||||
REFERENCES Shop_Recurrence_Interval(id_interval),
|
||||
count_recurrence_interval INTEGER,
|
||||
id_unit_measurement_interval_recurrence INTEGER,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_unit_measurement_interval_recurrence
|
||||
FOREIGN KEY (id_unit_measurement_interval_recurrence)
|
||||
REFERENCES Shop_Interval_Recurrence(id_interval),
|
||||
count_interval_recurrence INTEGER,
|
||||
id_stripe_product VARCHAR(100),
|
||||
product_has_variations INTEGER NOT NULL,
|
||||
can_view BOOLEAN,
|
||||
@@ -325,14 +325,14 @@ BEGIN
|
||||
price_GBP_VAT_excl,
|
||||
price_GBP_min,
|
||||
*/
|
||||
latency_manufacture,
|
||||
latency_manufacture_days,
|
||||
quantity_min,
|
||||
quantity_max,
|
||||
quantity_step,
|
||||
quantity_stock,
|
||||
is_subscription,
|
||||
id_recurrence_interval,
|
||||
count_recurrence_interval,
|
||||
id_unit_measurement_interval_recurrence,
|
||||
count_interval_recurrence,
|
||||
id_stripe_product,
|
||||
product_has_variations
|
||||
*/
|
||||
@@ -357,14 +357,14 @@ BEGIN
|
||||
PP.price_GBP_VAT_excl,
|
||||
PP.price_GBP_min,
|
||||
*/
|
||||
PP.latency_manufacture,
|
||||
PP.latency_manufacture_days,
|
||||
PP.quantity_min,
|
||||
PP.quantity_max,
|
||||
PP.quantity_step,
|
||||
PP.quantity_stock,
|
||||
PP.is_subscription,
|
||||
PP.id_recurrence_interval,
|
||||
PP.count_recurrence_interval,
|
||||
PP.id_unit_measurement_interval_recurrence,
|
||||
PP.count_interval_recurrence,
|
||||
PP.id_stripe_product,
|
||||
P.has_variations
|
||||
*/
|
||||
|
||||
@@ -147,17 +147,17 @@ BEGIN
|
||||
price_GBP_min REAL NOT NULL,
|
||||
*/
|
||||
/*
|
||||
latency_manufacture INTEGER NOT NULL,
|
||||
latency_manufacture_days INTEGER NOT NULL,
|
||||
quantity_min REAL NOT NULL,
|
||||
quantity_max REAL NOT NULL,
|
||||
quantity_step REAL NOT NULL,
|
||||
quantity_stock REAL NOT NULL,
|
||||
is_subscription BOOLEAN NOT NULL,
|
||||
id_recurrence_interval INTEGER,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_recurrence_interval
|
||||
FOREIGN KEY (id_recurrence_interval)
|
||||
REFERENCES Shop_Recurrence_Interval(id_interval),
|
||||
count_recurrence_interval INTEGER,
|
||||
id_unit_measurement_interval_recurrence INTEGER,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_unit_measurement_interval_recurrence
|
||||
FOREIGN KEY (id_unit_measurement_interval_recurrence)
|
||||
REFERENCES Shop_Interval_Recurrence(id_interval),
|
||||
count_interval_recurrence INTEGER,
|
||||
id_stripe_product VARCHAR(100),
|
||||
product_has_variations INTEGER NOT NULL,
|
||||
*/
|
||||
@@ -251,14 +251,14 @@ BEGIN
|
||||
price_GBP_VAT_excl,
|
||||
price_GBP_min,
|
||||
*/
|
||||
latency_manufacture,
|
||||
latency_manufacture_days,
|
||||
quantity_min,
|
||||
quantity_max,
|
||||
quantity_step,
|
||||
quantity_stock,
|
||||
is_subscription,
|
||||
id_recurrence_interval,
|
||||
count_recurrence_interval,
|
||||
id_unit_measurement_interval_recurrence,
|
||||
count_interval_recurrence,
|
||||
id_stripe_product,
|
||||
product_has_variations
|
||||
*/
|
||||
@@ -283,14 +283,14 @@ BEGIN
|
||||
PP.price_GBP_VAT_excl,
|
||||
PP.price_GBP_min,
|
||||
*/
|
||||
PP.latency_manufacture,
|
||||
PP.latency_manufacture_days,
|
||||
PP.quantity_min,
|
||||
PP.quantity_max,
|
||||
PP.quantity_step,
|
||||
PP.quantity_stock,
|
||||
PP.is_subscription,
|
||||
PP.id_recurrence_interval,
|
||||
PP.count_recurrence_interval,
|
||||
PP.id_unit_measurement_interval_recurrence,
|
||||
PP.count_interval_recurrence,
|
||||
PP.id_stripe_product,
|
||||
P.has_variations
|
||||
*/
|
||||
|
||||
@@ -179,17 +179,17 @@ BEGIN
|
||||
price_GBP_min REAL NOT NULL,
|
||||
*/
|
||||
/*
|
||||
latency_manufacture INTEGER NOT NULL,
|
||||
latency_manufacture_days INTEGER NOT NULL,
|
||||
quantity_min REAL NOT NULL,
|
||||
quantity_max REAL NOT NULL,
|
||||
quantity_step REAL NOT NULL,
|
||||
quantity_stock REAL NOT NULL,
|
||||
is_subscription BOOLEAN NOT NULL,
|
||||
id_recurrence_interval INTEGER,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_recurrence_interval
|
||||
FOREIGN KEY (id_recurrence_interval)
|
||||
REFERENCES Shop_Recurrence_Interval(id_interval),
|
||||
count_recurrence_interval INTEGER,
|
||||
id_unit_measurement_interval_recurrence INTEGER,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_unit_measurement_interval_recurrence
|
||||
FOREIGN KEY (id_unit_measurement_interval_recurrence)
|
||||
REFERENCES Shop_Interval_Recurrence(id_interval),
|
||||
count_interval_recurrence INTEGER,
|
||||
id_stripe_product VARCHAR(100),
|
||||
product_has_variations INTEGER NOT NULL,
|
||||
*/
|
||||
@@ -335,14 +335,14 @@ BEGIN
|
||||
price_GBP_VAT_excl,
|
||||
price_GBP_min,
|
||||
*/
|
||||
latency_manufacture,
|
||||
latency_manufacture_days,
|
||||
quantity_min,
|
||||
quantity_max,
|
||||
quantity_step,
|
||||
quantity_stock,
|
||||
is_subscription,
|
||||
id_recurrence_interval,
|
||||
count_recurrence_interval,
|
||||
id_unit_measurement_interval_recurrence,
|
||||
count_interval_recurrence,
|
||||
id_stripe_product,
|
||||
product_has_variations
|
||||
*/
|
||||
@@ -367,14 +367,14 @@ BEGIN
|
||||
PP.price_GBP_VAT_excl,
|
||||
PP.price_GBP_min,
|
||||
*/
|
||||
PP.latency_manufacture,
|
||||
PP.latency_manufacture_days,
|
||||
PP.quantity_min,
|
||||
PP.quantity_max,
|
||||
PP.quantity_step,
|
||||
PP.quantity_stock,
|
||||
PP.is_subscription,
|
||||
PP.id_recurrence_interval,
|
||||
PP.count_recurrence_interval,
|
||||
PP.id_unit_measurement_interval_recurrence,
|
||||
PP.count_interval_recurrence,
|
||||
PP.id_stripe_product,
|
||||
P.has_variations
|
||||
*/
|
||||
|
||||
@@ -75,7 +75,7 @@ VALUES
|
||||
;
|
||||
|
||||
-- Recurrence Interval
|
||||
INSERT INTO Shop_Recurrence_Interval (
|
||||
INSERT INTO Shop_Interval_Recurrence (
|
||||
code, name, name_plural
|
||||
)
|
||||
VALUES
|
||||
@@ -198,14 +198,14 @@ INSERT INTO Shop_Product_Permutation (
|
||||
id_currency_cost,
|
||||
profit_local_min,
|
||||
-- id_currency_profit_min,
|
||||
latency_manufacture,
|
||||
latency_manufacture_days,
|
||||
quantity_min,
|
||||
quantity_max,
|
||||
quantity_step,
|
||||
quantity_stock,
|
||||
is_subscription,
|
||||
id_recurrence_interval,
|
||||
count_recurrence_interval,
|
||||
id_unit_measurement_interval_recurrence,
|
||||
count_interval_recurrence,
|
||||
-- id_access_level_required,
|
||||
id_stripe_product
|
||||
)
|
||||
|
||||
@@ -31,8 +31,8 @@ SELECT * FROM Shop_Product_Category;
|
||||
SELECT * FROM Shop_Product_Category_Audit;
|
||||
|
||||
-- Recurrence Interval
|
||||
SELECT * FROM Shop_Recurrence_Interval;
|
||||
SELECT * FROM Shop_Recurrence_Interval_Audit;
|
||||
SELECT * FROM Shop_Interval_Recurrence;
|
||||
SELECT * FROM Shop_Interval_Recurrence_Audit;
|
||||
|
||||
-- Region
|
||||
SELECT * FROM Shop_Region;
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
105_tbl_Shop_General_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
|
||||
108_tbl_Shop_Interval_Recurrence.sql
|
||||
109_tbl_Shop_Interval_Recurrence_Audit.sql
|
||||
110.0_tbl_Shop_Region.sql
|
||||
110.1_tbl_Shop_Region_Audit.sql
|
||||
110.2_tbl_Shop_Region_Branch.sql
|
||||
@@ -94,7 +94,7 @@
|
||||
303_tri_File_Type_Audit.sql
|
||||
304_tri_Shop_General.sql
|
||||
306_tri_Shop_Product_Category.sql
|
||||
308_tri_Shop_Recurrence_Interval.sql
|
||||
308_tri_Shop_Interval_Recurrence.sql
|
||||
310.0_tri_Shop_Region.sql
|
||||
310.2_tri_Shop_Region_Branch.sql
|
||||
310.4_tri_Shop_Currency.sql
|
||||
|
||||
35
static/css/components/table.css
Normal file
35
static/css/components/table.css
Normal file
@@ -0,0 +1,35 @@
|
||||
|
||||
thead, tbody {
|
||||
padding-top: 0px !important;
|
||||
padding-bottom: 0px !important;
|
||||
}
|
||||
|
||||
th {
|
||||
|
||||
}
|
||||
td {
|
||||
font-size: min(12px, calc(1vh * 3));
|
||||
}
|
||||
|
||||
th, td {
|
||||
min-width: fit-content;
|
||||
}
|
||||
tr:not(:last-child) > td {
|
||||
border-bottom: 1px dashed var(--c_purple_dark);
|
||||
}
|
||||
td > table > tbody > tr > td {
|
||||
border: none !important;
|
||||
}
|
||||
tr {
|
||||
min-height: 1px;
|
||||
border-bottom: 1px solid var(--c_purple_dark);
|
||||
border-top: 1px solid var(--c_purple_dark);
|
||||
padding-bottom: 1vh;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
/*
|
||||
.row-new {
|
||||
visibility: hidden;
|
||||
}
|
||||
*/
|
||||
@@ -0,0 +1,15 @@
|
||||
|
||||
|
||||
button.collapsed {
|
||||
display: block;
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
form.filter button.save, form.filter button.button-cancel {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
form.filter button.save, form.filter button.button-cancel {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
15
static/css/layouts/table-main.css
Normal file
15
static/css/layouts/table-main.css
Normal file
@@ -0,0 +1,15 @@
|
||||
#tableMain {
|
||||
overflow-x: auto;
|
||||
padding: 1vh 2vh;
|
||||
max-width: min(calc(1vh * 80), calc(1vw * 90));
|
||||
width: fit-content;
|
||||
margin: 1vh 2vh;
|
||||
align-items: normal;
|
||||
justify-content: normal;
|
||||
}
|
||||
|
||||
#tableMain thead tr th, #tableMain tbody tr td {
|
||||
width: 20vh;
|
||||
min-width: 20vh;
|
||||
padding: 0 0.5vh;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
/*
|
||||
|
||||
/* Base styles *
|
||||
@import 'lib/reset.css';
|
||||
@import 'lib/typography.css';
|
||||
@@ -9,6 +9,7 @@
|
||||
/* Layout styles *
|
||||
@import 'layouts/header.css';
|
||||
@import 'layouts/footer.css';
|
||||
@import 'layouts/table-main.css';
|
||||
|
||||
/* Component styles *
|
||||
@import 'components/button.css';
|
||||
@@ -21,6 +22,7 @@
|
||||
|
||||
/* Section styles *
|
||||
@import 'sections/store.css';
|
||||
*/
|
||||
|
||||
/* Page-specific styles *
|
||||
@import 'pages/page_admin.css';
|
||||
@@ -31,15 +33,14 @@
|
||||
@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'; *
|
||||
/* Uncomment the line below to enable dark theme */
|
||||
/* @import 'themes/dark.css'; */
|
||||
|
||||
|
||||
*/
|
||||
|
||||
/* Custom styles */
|
||||
/* Add any custom styles or overrides here */
|
||||
@@ -234,10 +235,9 @@ h5 {
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
align-self: center;
|
||||
font-size: min(20px, calc(1vh * 6));
|
||||
font-size: min(16px, calc(1vh * 4));
|
||||
}
|
||||
#pageBody > * > * {
|
||||
width: 100%;
|
||||
align-self: center;
|
||||
padding-top: 1vh;
|
||||
padding-bottom: 1vh;
|
||||
@@ -374,6 +374,7 @@ img.header-logo {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
margin: auto 0;
|
||||
}
|
||||
|
||||
.row {
|
||||
@@ -521,10 +522,10 @@ button:hover, input[type="submit"]:hover, #overlayHamburger .row *:hover {
|
||||
z-index: 999;
|
||||
}
|
||||
.overlay.expanded {
|
||||
display: block !important;
|
||||
display: block;
|
||||
}
|
||||
.collapsed {
|
||||
display: none !important;
|
||||
display: none;
|
||||
}
|
||||
|
||||
#overlayHamburger {
|
||||
@@ -593,39 +594,5 @@ td.dirty {
|
||||
|
||||
/* Tables */
|
||||
#pageBody > *, button {
|
||||
font-size: min(14px, calc(1vh * 5)) !important;
|
||||
}
|
||||
thead, tbody {
|
||||
padding-top: 0px !important;
|
||||
padding-bottom: 0px !important;
|
||||
}
|
||||
|
||||
th {
|
||||
|
||||
}
|
||||
td {
|
||||
font-size: min(14px, calc(1vh * 5));
|
||||
}
|
||||
|
||||
th, td {
|
||||
min-width: fit-content;
|
||||
}
|
||||
tr:not(:last-child) > td {
|
||||
border-bottom: 1px dashed var(--c_purple_dark);
|
||||
}
|
||||
td > table > tbody > tr > td {
|
||||
border: none !important;
|
||||
}
|
||||
tr {
|
||||
min-height: 1px;
|
||||
border-bottom: 1px solid var(--c_purple_dark);
|
||||
border-top: 1px solid var(--c_purple_dark);
|
||||
padding-bottom: 1vh;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
/*
|
||||
.row-new {
|
||||
visibility: hidden;
|
||||
}
|
||||
*/
|
||||
font-size: min(12px, calc(1vh * 3));
|
||||
}
|
||||
@@ -1,4 +1,7 @@
|
||||
|
||||
#pageBody > * > * {
|
||||
width: 100%;
|
||||
}
|
||||
#pageBody > * {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
@@ -1,23 +1,58 @@
|
||||
|
||||
#formFilters {
|
||||
width: 50vh;
|
||||
}
|
||||
|
||||
td.display-order, th.display-order {
|
||||
width: 8% !important;
|
||||
#formFilters .container {
|
||||
max-width: fit-content;
|
||||
}
|
||||
td.code, th.code {
|
||||
width: 15% !important;
|
||||
|
||||
#formFilters .container-input.filter.is_not_empty {
|
||||
width: 10vh;
|
||||
}
|
||||
|
||||
#formFilters .container-input.filter.active {
|
||||
width: 8vh;
|
||||
}
|
||||
td.name, th.name {
|
||||
width: 25% !important;
|
||||
|
||||
#tableMain {
|
||||
max-width: min(calc(1vh * 79), calc(1vw * 90));
|
||||
}
|
||||
td.description, th.description {
|
||||
width: 35% !important;
|
||||
|
||||
/*
|
||||
#tableMain thead tr th, #tableMain tbody tr td {
|
||||
margin-left: 1vh;
|
||||
margin-right: 1vh;
|
||||
}
|
||||
td.access_level, th.access_level {
|
||||
width: 10% !important;
|
||||
*/
|
||||
|
||||
#tableMain tbody tr td.display_order, #tableMain thead tr th.display_order {
|
||||
width: 5vh;
|
||||
min-width: 5vh;
|
||||
}
|
||||
td.active, th.active {
|
||||
width: 7% !important;
|
||||
#tableMain tbody tr td.code, #tableMain thead tr th.code {
|
||||
width: 10vh;
|
||||
min-width: 10vh;
|
||||
}
|
||||
#tableMain tbody tr td.name, #tableMain thead tr th.name {
|
||||
width: 15vh;
|
||||
min-width: 15vh;
|
||||
}
|
||||
#tableMain tbody tr td.description, #tableMain thead tr th.description {
|
||||
width: 25vh;
|
||||
min-width: 25vh;
|
||||
}
|
||||
#tableMain tbody tr td.access_level, #tableMain thead tr th.access_level {
|
||||
width: 7vh;
|
||||
min-width: 7vh;
|
||||
}
|
||||
#tableMain tbody tr td.active, #tableMain thead tr th.active {
|
||||
width: 5vh;
|
||||
min-width: 5vh;
|
||||
}
|
||||
/*
|
||||
nips
|
||||
*/
|
||||
|
||||
/*
|
||||
.row-new {
|
||||
@@ -26,15 +61,15 @@ td.active, th.active {
|
||||
*/
|
||||
|
||||
textarea {
|
||||
width: 95% !important;
|
||||
width: 95%;
|
||||
}
|
||||
|
||||
select {
|
||||
width: 100% !important;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
input {
|
||||
width: 90% !important;
|
||||
width: 90%;
|
||||
}
|
||||
|
||||
td > input, td > select, td > textarea, .container-input > input, .container-input > select, .container-input > textarea {
|
||||
|
||||
@@ -1,28 +1,110 @@
|
||||
|
||||
#formFilters {
|
||||
width: 50vh;
|
||||
}
|
||||
|
||||
#formFilters .container {
|
||||
max-width: fit-content;
|
||||
}
|
||||
|
||||
|
||||
td.category, th.category {
|
||||
width: 16% !important;
|
||||
#tableMain {
|
||||
max-width: 90vw;
|
||||
}
|
||||
td.product, th.product {
|
||||
width: 23% !important;
|
||||
#tableMain thead tr th.category, #tableMain tbody tr td.category {
|
||||
width: 8vh;
|
||||
min-width: 8vh;
|
||||
}
|
||||
td.variations, th.variations {
|
||||
width: 19% !important;
|
||||
#tableMain thead tr th.product, #tableMain tbody tr td.product {
|
||||
width: 10vh;
|
||||
min-width: 10vh;
|
||||
}
|
||||
td.quantity-stock, th.quantity-stock {
|
||||
width: 10% !important;
|
||||
#tableMain thead tr th.product_variations.collapsed, #tableMain tbody tr td.product_variations.collapsed {
|
||||
width: 10vh;
|
||||
min-width: 10vh;
|
||||
display: table-cell !important;
|
||||
}
|
||||
td.quantity-min, th.quantity-min {
|
||||
width: 10% !important;
|
||||
#tableMain thead tr th.product_variations, #tableMain tbody tr td.product_variations {
|
||||
width: 20vh;
|
||||
min-width: 20vh;
|
||||
}
|
||||
td.quantity-max, th.quantity-max {
|
||||
width: 10% !important;
|
||||
#tableMain tbody tr td.product_variations table thead tr th, #tableMain tbody tr td.product_variations table tbody tr td {
|
||||
width: 8vh;
|
||||
min-width: 8vh;
|
||||
}
|
||||
td.cost-local-VAT-incl, th.cost-local-VAT-incl {
|
||||
width: 6% !important;
|
||||
#tableMain tbody tr td.product_variations table thead tr th:last-of-type, #tableMain tbody tr td.product_variations table tbody tr td:last-of-type {
|
||||
width: 4vh;
|
||||
min-width: 4vh;
|
||||
}
|
||||
td.detail, th.detail {
|
||||
width: 6% !important;
|
||||
#tableMain thead tr th.description, #tableMain tbody tr td.description {
|
||||
}
|
||||
#tableMain thead tr th.quantity_stock, #tableMain tbody tr td.quantity_stock {
|
||||
width: 6vh;
|
||||
min-width: 6vh;
|
||||
}
|
||||
#tableMain thead tr th.quantity_min, #tableMain tbody tr td.quantity_min {
|
||||
width: 6vh;
|
||||
min-width: 6vh;
|
||||
}
|
||||
#tableMain thead tr th.quantity_max, #tableMain tbody tr td.quantity_max {
|
||||
width: 6vh;
|
||||
min-width: 6vh;
|
||||
}
|
||||
#tableMain thead tr th.count_unit_measurement_per_quantity_step, #tableMain tbody tr td.count_unit_measurement_per_quantity_step {
|
||||
width: 6vh;
|
||||
min-width: 6vh;
|
||||
}
|
||||
#tableMain thead tr th.id_unit_measurement_quantity, #tableMain tbody tr td.id_unit_measurement_quantity {
|
||||
width: 8vh;
|
||||
min-width: 8vh;
|
||||
}
|
||||
#tableMain thead tr th.is_subscription, #tableMain tbody tr td.is_subscription {
|
||||
width: 9vh;
|
||||
min-width: 9vh;
|
||||
}
|
||||
#tableMain thead tr th.count_interval_recurrence, #tableMain tbody tr td.count_interval_recurrence {
|
||||
width: 8vh;
|
||||
min-width: 8vh;
|
||||
}
|
||||
#tableMain thead tr th.id_unit_measurement_interval_recurrence, #tableMain tbody tr td.id_unit_measurement_interval_recurrence {
|
||||
width: 8vh;
|
||||
min-width: 8vh;
|
||||
}
|
||||
#tableMain thead tr th.id_stripe_product, #tableMain tbody tr td.id_stripe_product {
|
||||
width: 10vh;
|
||||
min-width: 10vh;
|
||||
}
|
||||
#tableMain thead tr th.does_expire_faster_once_unsealed, #tableMain tbody tr td.does_expire_faster_once_unsealed {
|
||||
width: 7vh;
|
||||
min-width: 7vh;
|
||||
}
|
||||
#tableMain thead tr th.count_interval_expiration_unsealed, #tableMain tbody tr td.count_interval_expiration_unsealed {
|
||||
width: 8vh;
|
||||
min-width: 8vh;
|
||||
}
|
||||
#tableMain thead tr th.id_unit_measurement_interval_expiration_unsealed, #tableMain tbody tr td.id_unit_measurement_interval_expiration_unsealed {
|
||||
width: 8vh;
|
||||
min-width: 8vh;
|
||||
}
|
||||
#tableMain thead tr th.cost_local, #tableMain tbody tr td.cost_local {
|
||||
width: 9vh;
|
||||
min-width: 9vh;
|
||||
}
|
||||
#tableMain thead tr th.id_currency_cost, #tableMain tbody tr td.id_currency_cost {
|
||||
width: 6vh;
|
||||
min-width: 6vh;
|
||||
}
|
||||
#tableMain thead tr th.profit_local_min, #tableMain tbody tr td.profit_local_min {
|
||||
width: 9vh;
|
||||
min-width: 9vh;
|
||||
}
|
||||
#tableMain thead tr th.latency_manufacture_days, #tableMain tbody tr td.latency_manufacture_days {
|
||||
width: 9vh;
|
||||
min-width: 9vh;
|
||||
}
|
||||
#tableMain thead tr th.active, #tableMain tbody tr td.active {
|
||||
width: 6vh;
|
||||
min-width: 6vh;
|
||||
}
|
||||
|
||||
textarea {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
.img-product {
|
||||
max-width: 20vh;
|
||||
max-height: 20vh;
|
||||
@@ -12,7 +13,7 @@
|
||||
justify-self: left;
|
||||
}
|
||||
|
||||
.buttonAdd2Basket {
|
||||
.buttonAddToBasket {
|
||||
background-color: var(--c_blue_pastel);
|
||||
color: var(--c_blue_dark);
|
||||
border-color: var(--c_blue_dark);
|
||||
|
||||
1
static/dist/css/416.bundle.css
vendored
Normal file
1
static/dist/css/416.bundle.css
vendored
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
3
static/dist/css/core_home.bundle.css
vendored
3
static/dist/css/core_home.bundle.css
vendored
@@ -1,4 +1,7 @@
|
||||
|
||||
#pageBody > * > * {
|
||||
width: 100%;
|
||||
}
|
||||
#pageBody > * {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
184
static/dist/css/main.bundle.css
vendored
184
static/dist/css/main.bundle.css
vendored
@@ -1,75 +1,5 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#overlayConfirm {
|
||||
position: absolute;
|
||||
left: 25vw;
|
||||
width: 50vw;
|
||||
height: 50vh;
|
||||
}
|
||||
.img-product {
|
||||
max-width: 20vh;
|
||||
max-height: 20vh;
|
||||
border-radius: 3vh;
|
||||
justify-self: left;
|
||||
}
|
||||
|
||||
.img-thumbnail {
|
||||
max-width: 10vh;
|
||||
max-height: 10vh;
|
||||
border-radius: 3vh;
|
||||
justify-self: left;
|
||||
}
|
||||
|
||||
.buttonAdd2Basket {
|
||||
background-color: var(--c_blue_pastel);
|
||||
color: var(--c_blue_dark);
|
||||
border-color: var(--c_blue_dark);
|
||||
}
|
||||
|
||||
#buttonCheckout, .buttonBuyNow {
|
||||
background-color: var(--c_purple_pastel);
|
||||
color: var(--c_purple_dark);
|
||||
border-color: var(--c_purple_dark);
|
||||
}
|
||||
|
||||
.button-increment, .button-decrement {
|
||||
border: 2px solid darkgrey;
|
||||
background-color: lightgray;
|
||||
margin: 1vh 1vh;
|
||||
width: 2.5vh;
|
||||
height: 2.5vh;
|
||||
border-radius: 1.25vh;
|
||||
font-size: 2vh;
|
||||
}
|
||||
|
||||
.container-input > input {
|
||||
padding: 0vh 1vh;
|
||||
border-radius: 0.5vh;
|
||||
max-width: 7vh;
|
||||
}
|
||||
|
||||
#basket {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Right column */
|
||||
.rightcolumn {
|
||||
min-width: fit-content;
|
||||
}
|
||||
|
||||
/*
|
||||
/* Base styles *
|
||||
@import 'lib/reset.css';
|
||||
@import 'lib/typography.css';
|
||||
@@ -79,6 +9,7 @@
|
||||
/* Layout styles *
|
||||
@import 'layouts/header.css';
|
||||
@import 'layouts/footer.css';
|
||||
@import 'layouts/table-main.css';
|
||||
|
||||
/* Component styles *
|
||||
@import 'components/button.css';
|
||||
@@ -91,6 +22,7 @@
|
||||
|
||||
/* Section styles *
|
||||
@import 'sections/store.css';
|
||||
*/
|
||||
|
||||
/* Page-specific styles *
|
||||
@import 'pages/page_admin.css';
|
||||
@@ -101,15 +33,14 @@
|
||||
@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'; *
|
||||
/* Uncomment the line below to enable dark theme */
|
||||
/* @import 'themes/dark.css'; */
|
||||
|
||||
|
||||
*/
|
||||
|
||||
/* Custom styles */
|
||||
/* Add any custom styles or overrides here */
|
||||
@@ -304,10 +235,9 @@ h5 {
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
align-self: center;
|
||||
font-size: min(20px, calc(1vh * 6));
|
||||
font-size: min(16px, calc(1vh * 4));
|
||||
}
|
||||
#pageBody > * > * {
|
||||
width: 100%;
|
||||
align-self: center;
|
||||
padding-top: 1vh;
|
||||
padding-bottom: 1vh;
|
||||
@@ -444,6 +374,7 @@ img.header-logo {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
margin: auto 0;
|
||||
}
|
||||
|
||||
.row {
|
||||
@@ -591,10 +522,10 @@ button:hover, input[type="submit"]:hover, #overlayHamburger .row *:hover {
|
||||
z-index: 999;
|
||||
}
|
||||
.overlay.expanded {
|
||||
display: block !important;
|
||||
display: block;
|
||||
}
|
||||
.collapsed {
|
||||
display: none !important;
|
||||
display: none;
|
||||
}
|
||||
|
||||
#overlayHamburger {
|
||||
@@ -663,8 +594,21 @@ td.dirty {
|
||||
|
||||
/* Tables */
|
||||
#pageBody > *, button {
|
||||
font-size: min(14px, calc(1vh * 5)) !important;
|
||||
font-size: min(12px, calc(1vh * 3));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#overlayConfirm {
|
||||
position: absolute;
|
||||
left: 25vw;
|
||||
width: 50vw;
|
||||
height: 50vh;
|
||||
}
|
||||
|
||||
thead, tbody {
|
||||
padding-top: 0px !important;
|
||||
padding-bottom: 0px !important;
|
||||
@@ -674,7 +618,7 @@ th {
|
||||
|
||||
}
|
||||
td {
|
||||
font-size: min(14px, calc(1vh * 5));
|
||||
font-size: min(12px, calc(1vh * 3));
|
||||
}
|
||||
|
||||
th, td {
|
||||
@@ -700,3 +644,83 @@ tr {
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
button.collapsed {
|
||||
display: block;
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
form.filter button.save, form.filter button.button-cancel {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
form.filter button.save, form.filter button.button-cancel {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
#tableMain {
|
||||
overflow-x: auto;
|
||||
padding: 1vh 2vh;
|
||||
max-width: min(calc(1vh * 80), calc(1vw * 90));
|
||||
width: fit-content;
|
||||
margin: 1vh 2vh;
|
||||
align-items: normal;
|
||||
justify-content: normal;
|
||||
}
|
||||
|
||||
#tableMain thead tr th, #tableMain tbody tr td {
|
||||
width: 20vh;
|
||||
min-width: 20vh;
|
||||
padding: 0 0.5vh;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
: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 */
|
||||
--Button-primary-bg: #007bff;
|
||||
--Button-primary-text: #ffffff;
|
||||
--Button-secondary-bg: #6c757d;
|
||||
--Button-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);
|
||||
}
|
||||
|
||||
2
static/dist/css/main.css
vendored
2
static/dist/css/main.css
vendored
@@ -30,7 +30,7 @@
|
||||
justify-self: left;
|
||||
}
|
||||
|
||||
.buttonAdd2Basket {
|
||||
.buttonAddToBasket {
|
||||
background-color: var(--c_blue_pastel);
|
||||
color: var(--c_blue_dark);
|
||||
border-color: var(--c_blue_dark);
|
||||
|
||||
53
static/dist/css/store_home.bundle.css
vendored
53
static/dist/css/store_home.bundle.css
vendored
@@ -1 +1,54 @@
|
||||
|
||||
.img-product {
|
||||
max-width: 20vh;
|
||||
max-height: 20vh;
|
||||
border-radius: 3vh;
|
||||
justify-self: left;
|
||||
}
|
||||
|
||||
.img-thumbnail {
|
||||
max-width: 10vh;
|
||||
max-height: 10vh;
|
||||
border-radius: 3vh;
|
||||
justify-self: left;
|
||||
}
|
||||
|
||||
.buttonAddToBasket {
|
||||
background-color: var(--c_blue_pastel);
|
||||
color: var(--c_blue_dark);
|
||||
border-color: var(--c_blue_dark);
|
||||
}
|
||||
|
||||
#buttonCheckout, .buttonBuyNow {
|
||||
background-color: var(--c_purple_pastel);
|
||||
color: var(--c_purple_dark);
|
||||
border-color: var(--c_purple_dark);
|
||||
}
|
||||
|
||||
.button-increment, .button-decrement {
|
||||
border: 2px solid darkgrey;
|
||||
background-color: lightgray;
|
||||
margin: 1vh 1vh;
|
||||
width: 2.5vh;
|
||||
height: 2.5vh;
|
||||
border-radius: 1.25vh;
|
||||
font-size: 2vh;
|
||||
}
|
||||
|
||||
.container-input > input {
|
||||
padding: 0vh 1vh;
|
||||
border-radius: 0.5vh;
|
||||
max-width: 7vh;
|
||||
}
|
||||
|
||||
#basket {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Right column */
|
||||
.rightcolumn {
|
||||
min-width: fit-content;
|
||||
}
|
||||
|
||||
|
||||
118
static/dist/css/store_product_categories.bundle.css
vendored
118
static/dist/css/store_product_categories.bundle.css
vendored
@@ -1,23 +1,111 @@
|
||||
|
||||
.img-product {
|
||||
max-width: 20vh;
|
||||
max-height: 20vh;
|
||||
border-radius: 3vh;
|
||||
justify-self: left;
|
||||
}
|
||||
|
||||
.img-thumbnail {
|
||||
max-width: 10vh;
|
||||
max-height: 10vh;
|
||||
border-radius: 3vh;
|
||||
justify-self: left;
|
||||
}
|
||||
|
||||
.buttonAddToBasket {
|
||||
background-color: var(--c_blue_pastel);
|
||||
color: var(--c_blue_dark);
|
||||
border-color: var(--c_blue_dark);
|
||||
}
|
||||
|
||||
#buttonCheckout, .buttonBuyNow {
|
||||
background-color: var(--c_purple_pastel);
|
||||
color: var(--c_purple_dark);
|
||||
border-color: var(--c_purple_dark);
|
||||
}
|
||||
|
||||
.button-increment, .button-decrement {
|
||||
border: 2px solid darkgrey;
|
||||
background-color: lightgray;
|
||||
margin: 1vh 1vh;
|
||||
width: 2.5vh;
|
||||
height: 2.5vh;
|
||||
border-radius: 1.25vh;
|
||||
font-size: 2vh;
|
||||
}
|
||||
|
||||
.container-input > input {
|
||||
padding: 0vh 1vh;
|
||||
border-radius: 0.5vh;
|
||||
max-width: 7vh;
|
||||
}
|
||||
|
||||
#basket {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
|
||||
td.display-order, th.display-order {
|
||||
width: 8% !important;
|
||||
|
||||
/* Right column */
|
||||
.rightcolumn {
|
||||
min-width: fit-content;
|
||||
}
|
||||
td.code, th.code {
|
||||
width: 15% !important;
|
||||
|
||||
#formFilters {
|
||||
width: 50vh;
|
||||
}
|
||||
td.name, th.name {
|
||||
width: 25% !important;
|
||||
|
||||
#formFilters .container {
|
||||
max-width: fit-content;
|
||||
}
|
||||
td.description, th.description {
|
||||
width: 35% !important;
|
||||
|
||||
#formFilters .container-input.filter.is_not_empty {
|
||||
width: 10vh;
|
||||
}
|
||||
|
||||
#formFilters .container-input.filter.active {
|
||||
width: 8vh;
|
||||
}
|
||||
td.access_level, th.access_level {
|
||||
width: 10% !important;
|
||||
|
||||
#tableMain {
|
||||
max-width: min(calc(1vh * 79), calc(1vw * 90));
|
||||
}
|
||||
td.active, th.active {
|
||||
width: 7% !important;
|
||||
|
||||
/*
|
||||
#tableMain thead tr th, #tableMain tbody tr td {
|
||||
margin-left: 1vh;
|
||||
margin-right: 1vh;
|
||||
}
|
||||
*/
|
||||
|
||||
#tableMain tbody tr td.display_order, #tableMain thead tr th.display_order {
|
||||
width: 5vh;
|
||||
min-width: 5vh;
|
||||
}
|
||||
#tableMain tbody tr td.code, #tableMain thead tr th.code {
|
||||
width: 10vh;
|
||||
min-width: 10vh;
|
||||
}
|
||||
#tableMain tbody tr td.name, #tableMain thead tr th.name {
|
||||
width: 15vh;
|
||||
min-width: 15vh;
|
||||
}
|
||||
#tableMain tbody tr td.description, #tableMain thead tr th.description {
|
||||
width: 25vh;
|
||||
min-width: 25vh;
|
||||
}
|
||||
#tableMain tbody tr td.access_level, #tableMain thead tr th.access_level {
|
||||
width: 7vh;
|
||||
min-width: 7vh;
|
||||
}
|
||||
#tableMain tbody tr td.active, #tableMain thead tr th.active {
|
||||
width: 5vh;
|
||||
min-width: 5vh;
|
||||
}
|
||||
/*
|
||||
nips
|
||||
*/
|
||||
|
||||
/*
|
||||
.row-new {
|
||||
@@ -26,15 +114,15 @@ td.active, th.active {
|
||||
*/
|
||||
|
||||
textarea {
|
||||
width: 95% !important;
|
||||
width: 95%;
|
||||
}
|
||||
|
||||
select {
|
||||
width: 100% !important;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
input {
|
||||
width: 90% !important;
|
||||
width: 90%;
|
||||
}
|
||||
|
||||
td > input, td > select, td > textarea, .container-input > input, .container-input > select, .container-input > textarea {
|
||||
|
||||
@@ -1,28 +1,163 @@
|
||||
|
||||
.img-product {
|
||||
max-width: 20vh;
|
||||
max-height: 20vh;
|
||||
border-radius: 3vh;
|
||||
justify-self: left;
|
||||
}
|
||||
|
||||
.img-thumbnail {
|
||||
max-width: 10vh;
|
||||
max-height: 10vh;
|
||||
border-radius: 3vh;
|
||||
justify-self: left;
|
||||
}
|
||||
|
||||
.buttonAddToBasket {
|
||||
background-color: var(--c_blue_pastel);
|
||||
color: var(--c_blue_dark);
|
||||
border-color: var(--c_blue_dark);
|
||||
}
|
||||
|
||||
#buttonCheckout, .buttonBuyNow {
|
||||
background-color: var(--c_purple_pastel);
|
||||
color: var(--c_purple_dark);
|
||||
border-color: var(--c_purple_dark);
|
||||
}
|
||||
|
||||
.button-increment, .button-decrement {
|
||||
border: 2px solid darkgrey;
|
||||
background-color: lightgray;
|
||||
margin: 1vh 1vh;
|
||||
width: 2.5vh;
|
||||
height: 2.5vh;
|
||||
border-radius: 1.25vh;
|
||||
font-size: 2vh;
|
||||
}
|
||||
|
||||
.container-input > input {
|
||||
padding: 0vh 1vh;
|
||||
border-radius: 0.5vh;
|
||||
max-width: 7vh;
|
||||
}
|
||||
|
||||
#basket {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
|
||||
td.category, th.category {
|
||||
width: 16% !important;
|
||||
|
||||
/* Right column */
|
||||
.rightcolumn {
|
||||
min-width: fit-content;
|
||||
}
|
||||
td.product, th.product {
|
||||
width: 23% !important;
|
||||
|
||||
#formFilters {
|
||||
width: 50vh;
|
||||
}
|
||||
td.variations, th.variations {
|
||||
width: 19% !important;
|
||||
|
||||
#formFilters .container {
|
||||
max-width: fit-content;
|
||||
}
|
||||
td.quantity-stock, th.quantity-stock {
|
||||
width: 10% !important;
|
||||
|
||||
|
||||
#tableMain {
|
||||
max-width: 90vw;
|
||||
}
|
||||
td.quantity-min, th.quantity-min {
|
||||
width: 10% !important;
|
||||
#tableMain thead tr th.category, #tableMain tbody tr td.category {
|
||||
width: 8vh;
|
||||
min-width: 8vh;
|
||||
}
|
||||
td.quantity-max, th.quantity-max {
|
||||
width: 10% !important;
|
||||
#tableMain thead tr th.product, #tableMain tbody tr td.product {
|
||||
width: 10vh;
|
||||
min-width: 10vh;
|
||||
}
|
||||
td.cost-local-VAT-incl, th.cost-local-VAT-incl {
|
||||
width: 6% !important;
|
||||
#tableMain thead tr th.product_variations.collapsed, #tableMain tbody tr td.product_variations.collapsed {
|
||||
width: 10vh;
|
||||
min-width: 10vh;
|
||||
display: table-cell !important;
|
||||
}
|
||||
td.detail, th.detail {
|
||||
width: 6% !important;
|
||||
#tableMain thead tr th.product_variations, #tableMain tbody tr td.product_variations {
|
||||
width: 20vh;
|
||||
min-width: 20vh;
|
||||
}
|
||||
#tableMain tbody tr td.product_variations table thead tr th, #tableMain tbody tr td.product_variations table tbody tr td {
|
||||
width: 8vh;
|
||||
min-width: 8vh;
|
||||
}
|
||||
#tableMain tbody tr td.product_variations table thead tr th:last-of-type, #tableMain tbody tr td.product_variations table tbody tr td:last-of-type {
|
||||
width: 4vh;
|
||||
min-width: 4vh;
|
||||
}
|
||||
#tableMain thead tr th.description, #tableMain tbody tr td.description {
|
||||
}
|
||||
#tableMain thead tr th.quantity_stock, #tableMain tbody tr td.quantity_stock {
|
||||
width: 6vh;
|
||||
min-width: 6vh;
|
||||
}
|
||||
#tableMain thead tr th.quantity_min, #tableMain tbody tr td.quantity_min {
|
||||
width: 6vh;
|
||||
min-width: 6vh;
|
||||
}
|
||||
#tableMain thead tr th.quantity_max, #tableMain tbody tr td.quantity_max {
|
||||
width: 6vh;
|
||||
min-width: 6vh;
|
||||
}
|
||||
#tableMain thead tr th.count_unit_measurement_per_quantity_step, #tableMain tbody tr td.count_unit_measurement_per_quantity_step {
|
||||
width: 6vh;
|
||||
min-width: 6vh;
|
||||
}
|
||||
#tableMain thead tr th.id_unit_measurement_quantity, #tableMain tbody tr td.id_unit_measurement_quantity {
|
||||
width: 8vh;
|
||||
min-width: 8vh;
|
||||
}
|
||||
#tableMain thead tr th.is_subscription, #tableMain tbody tr td.is_subscription {
|
||||
width: 9vh;
|
||||
min-width: 9vh;
|
||||
}
|
||||
#tableMain thead tr th.count_interval_recurrence, #tableMain tbody tr td.count_interval_recurrence {
|
||||
width: 8vh;
|
||||
min-width: 8vh;
|
||||
}
|
||||
#tableMain thead tr th.id_unit_measurement_interval_recurrence, #tableMain tbody tr td.id_unit_measurement_interval_recurrence {
|
||||
width: 8vh;
|
||||
min-width: 8vh;
|
||||
}
|
||||
#tableMain thead tr th.id_stripe_product, #tableMain tbody tr td.id_stripe_product {
|
||||
width: 10vh;
|
||||
min-width: 10vh;
|
||||
}
|
||||
#tableMain thead tr th.does_expire_faster_once_unsealed, #tableMain tbody tr td.does_expire_faster_once_unsealed {
|
||||
width: 7vh;
|
||||
min-width: 7vh;
|
||||
}
|
||||
#tableMain thead tr th.count_interval_expiration_unsealed, #tableMain tbody tr td.count_interval_expiration_unsealed {
|
||||
width: 8vh;
|
||||
min-width: 8vh;
|
||||
}
|
||||
#tableMain thead tr th.id_unit_measurement_interval_expiration_unsealed, #tableMain tbody tr td.id_unit_measurement_interval_expiration_unsealed {
|
||||
width: 8vh;
|
||||
min-width: 8vh;
|
||||
}
|
||||
#tableMain thead tr th.cost_local, #tableMain tbody tr td.cost_local {
|
||||
width: 9vh;
|
||||
min-width: 9vh;
|
||||
}
|
||||
#tableMain thead tr th.id_currency_cost, #tableMain tbody tr td.id_currency_cost {
|
||||
width: 6vh;
|
||||
min-width: 6vh;
|
||||
}
|
||||
#tableMain thead tr th.profit_local_min, #tableMain tbody tr td.profit_local_min {
|
||||
width: 9vh;
|
||||
min-width: 9vh;
|
||||
}
|
||||
#tableMain thead tr th.latency_manufacture_days, #tableMain tbody tr td.latency_manufacture_days {
|
||||
width: 9vh;
|
||||
min-width: 9vh;
|
||||
}
|
||||
#tableMain thead tr th.active, #tableMain tbody tr td.active {
|
||||
width: 6vh;
|
||||
min-width: 6vh;
|
||||
}
|
||||
|
||||
textarea {
|
||||
|
||||
53
static/dist/css/store_stock_items.bundle.css
vendored
53
static/dist/css/store_stock_items.bundle.css
vendored
@@ -1,4 +1,57 @@
|
||||
|
||||
.img-product {
|
||||
max-width: 20vh;
|
||||
max-height: 20vh;
|
||||
border-radius: 3vh;
|
||||
justify-self: left;
|
||||
}
|
||||
|
||||
.img-thumbnail {
|
||||
max-width: 10vh;
|
||||
max-height: 10vh;
|
||||
border-radius: 3vh;
|
||||
justify-self: left;
|
||||
}
|
||||
|
||||
.buttonAddToBasket {
|
||||
background-color: var(--c_blue_pastel);
|
||||
color: var(--c_blue_dark);
|
||||
border-color: var(--c_blue_dark);
|
||||
}
|
||||
|
||||
#buttonCheckout, .buttonBuyNow {
|
||||
background-color: var(--c_purple_pastel);
|
||||
color: var(--c_purple_dark);
|
||||
border-color: var(--c_purple_dark);
|
||||
}
|
||||
|
||||
.button-increment, .button-decrement {
|
||||
border: 2px solid darkgrey;
|
||||
background-color: lightgray;
|
||||
margin: 1vh 1vh;
|
||||
width: 2.5vh;
|
||||
height: 2.5vh;
|
||||
border-radius: 1.25vh;
|
||||
font-size: 2vh;
|
||||
}
|
||||
|
||||
.container-input > input {
|
||||
padding: 0vh 1vh;
|
||||
border-radius: 0.5vh;
|
||||
max-width: 7vh;
|
||||
}
|
||||
|
||||
#basket {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Right column */
|
||||
.rightcolumn {
|
||||
min-width: fit-content;
|
||||
}
|
||||
|
||||
th, td {
|
||||
min-width: fit-content;
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
(()=>{"use strict";var r,e={780:()=>{},711:()=>{}},o={};function t(r){var a=o[r];if(void 0!==a)return a.exports;var n=o[r]={exports:{}};return e[r](n,n.exports,t),n.exports}t.m=e,r=[],t.O=(e,o,a,n)=>{if(!o){var i=1/0;for(f=0;f<r.length;f++){for(var[o,a,n]=r[f],p=!0,v=0;v<o.length;v++)(!1&n||i>=n)&&Object.keys(t.O).every((r=>t.O[r](o[v])))?o.splice(v--,1):(p=!1,n<i&&(i=n));if(p){r.splice(f--,1);var s=a();void 0!==s&&(e=s)}}return e}n=n||0;for(var f=r.length;f>0&&r[f-1][2]>n;f--)r[f]=r[f-1];r[f]=[o,a,n]},t.o=(r,e)=>Object.prototype.hasOwnProperty.call(r,e),(()=>{var r={841:0,466:0};t.O.j=e=>0===r[e];var e=(e,o)=>{var a,n,[i,p,v]=o,s=0;if(i.some((e=>0!==r[e]))){for(a in p)t.o(p,a)&&(t.m[a]=p[a]);if(v)var f=v(t)}for(e&&e(o);s<i.length;s++)n=i[s],t.o(r,n)&&r[n]&&r[n][0](),r[n]=0;return t.O(f)},o=self.webpackChunkapp=self.webpackChunkapp||[];o.forEach(e.bind(null,0)),o.push=e.bind(null,o.push.bind(o))})(),t.O(void 0,[466],(()=>t(711)));var a=t.O(void 0,[466],(()=>t(780)));a=t.O(a)})();
|
||||
(()=>{"use strict";var r,e={780:()=>{},359:()=>{}},o={};function t(r){var a=o[r];if(void 0!==a)return a.exports;var n=o[r]={exports:{}};return e[r](n,n.exports,t),n.exports}t.m=e,r=[],t.O=(e,o,a,n)=>{if(!o){var i=1/0;for(f=0;f<r.length;f++){for(var[o,a,n]=r[f],p=!0,v=0;v<o.length;v++)(!1&n||i>=n)&&Object.keys(t.O).every((r=>t.O[r](o[v])))?o.splice(v--,1):(p=!1,n<i&&(i=n));if(p){r.splice(f--,1);var s=a();void 0!==s&&(e=s)}}return e}n=n||0;for(var f=r.length;f>0&&r[f-1][2]>n;f--)r[f]=r[f-1];r[f]=[o,a,n]},t.o=(r,e)=>Object.prototype.hasOwnProperty.call(r,e),(()=>{var r={841:0,416:0};t.O.j=e=>0===r[e];var e=(e,o)=>{var a,n,[i,p,v]=o,s=0;if(i.some((e=>0!==r[e]))){for(a in p)t.o(p,a)&&(t.m[a]=p[a]);if(v)var f=v(t)}for(e&&e(o);s<i.length;s++)n=i[s],t.o(r,n)&&r[n]&&r[n][0](),r[n]=0;return t.O(f)},o=self.webpackChunkapp=self.webpackChunkapp||[];o.forEach(e.bind(null,0)),o.push=e.bind(null,o.push.bind(o))})(),t.O(void 0,[416],(()=>t(359)));var a=t.O(void 0,[416],(()=>t(780)));a=t.O(a)})();
|
||||
2
static/dist/js/legal_license.bundle.js
vendored
2
static/dist/js/legal_license.bundle.js
vendored
@@ -1 +1 @@
|
||||
(()=>{"use strict";var r,e={623:()=>{},711:()=>{}},o={};function t(r){var a=o[r];if(void 0!==a)return a.exports;var n=o[r]={exports:{}};return e[r](n,n.exports,t),n.exports}t.m=e,r=[],t.O=(e,o,a,n)=>{if(!o){var i=1/0;for(f=0;f<r.length;f++){for(var[o,a,n]=r[f],p=!0,v=0;v<o.length;v++)(!1&n||i>=n)&&Object.keys(t.O).every((r=>t.O[r](o[v])))?o.splice(v--,1):(p=!1,n<i&&(i=n));if(p){r.splice(f--,1);var s=a();void 0!==s&&(e=s)}}return e}n=n||0;for(var f=r.length;f>0&&r[f-1][2]>n;f--)r[f]=r[f-1];r[f]=[o,a,n]},t.o=(r,e)=>Object.prototype.hasOwnProperty.call(r,e),(()=>{var r={690:0,466:0};t.O.j=e=>0===r[e];var e=(e,o)=>{var a,n,[i,p,v]=o,s=0;if(i.some((e=>0!==r[e]))){for(a in p)t.o(p,a)&&(t.m[a]=p[a]);if(v)var f=v(t)}for(e&&e(o);s<i.length;s++)n=i[s],t.o(r,n)&&r[n]&&r[n][0](),r[n]=0;return t.O(f)},o=self.webpackChunkapp=self.webpackChunkapp||[];o.forEach(e.bind(null,0)),o.push=e.bind(null,o.push.bind(o))})(),t.O(void 0,[466],(()=>t(711)));var a=t.O(void 0,[466],(()=>t(623)));a=t.O(a)})();
|
||||
(()=>{"use strict";var r,e={623:()=>{},359:()=>{}},o={};function t(r){var a=o[r];if(void 0!==a)return a.exports;var n=o[r]={exports:{}};return e[r](n,n.exports,t),n.exports}t.m=e,r=[],t.O=(e,o,a,n)=>{if(!o){var i=1/0;for(f=0;f<r.length;f++){for(var[o,a,n]=r[f],p=!0,v=0;v<o.length;v++)(!1&n||i>=n)&&Object.keys(t.O).every((r=>t.O[r](o[v])))?o.splice(v--,1):(p=!1,n<i&&(i=n));if(p){r.splice(f--,1);var s=a();void 0!==s&&(e=s)}}return e}n=n||0;for(var f=r.length;f>0&&r[f-1][2]>n;f--)r[f]=r[f-1];r[f]=[o,a,n]},t.o=(r,e)=>Object.prototype.hasOwnProperty.call(r,e),(()=>{var r={690:0,416:0};t.O.j=e=>0===r[e];var e=(e,o)=>{var a,n,[i,p,v]=o,s=0;if(i.some((e=>0!==r[e]))){for(a in p)t.o(p,a)&&(t.m[a]=p[a]);if(v)var f=v(t)}for(e&&e(o);s<i.length;s++)n=i[s],t.o(r,n)&&r[n]&&r[n][0](),r[n]=0;return t.O(f)},o=self.webpackChunkapp=self.webpackChunkapp||[];o.forEach(e.bind(null,0)),o.push=e.bind(null,o.push.bind(o))})(),t.O(void 0,[416],(()=>t(359)));var a=t.O(void 0,[416],(()=>t(623)));a=t.O(a)})();
|
||||
@@ -1 +1 @@
|
||||
(()=>{"use strict";var r,e={713:()=>{},711:()=>{}},o={};function t(r){var a=o[r];if(void 0!==a)return a.exports;var n=o[r]={exports:{}};return e[r](n,n.exports,t),n.exports}t.m=e,r=[],t.O=(e,o,a,n)=>{if(!o){var i=1/0;for(f=0;f<r.length;f++){for(var[o,a,n]=r[f],p=!0,v=0;v<o.length;v++)(!1&n||i>=n)&&Object.keys(t.O).every((r=>t.O[r](o[v])))?o.splice(v--,1):(p=!1,n<i&&(i=n));if(p){r.splice(f--,1);var s=a();void 0!==s&&(e=s)}}return e}n=n||0;for(var f=r.length;f>0&&r[f-1][2]>n;f--)r[f]=r[f-1];r[f]=[o,a,n]},t.o=(r,e)=>Object.prototype.hasOwnProperty.call(r,e),(()=>{var r={364:0,466:0};t.O.j=e=>0===r[e];var e=(e,o)=>{var a,n,[i,p,v]=o,s=0;if(i.some((e=>0!==r[e]))){for(a in p)t.o(p,a)&&(t.m[a]=p[a]);if(v)var f=v(t)}for(e&&e(o);s<i.length;s++)n=i[s],t.o(r,n)&&r[n]&&r[n][0](),r[n]=0;return t.O(f)},o=self.webpackChunkapp=self.webpackChunkapp||[];o.forEach(e.bind(null,0)),o.push=e.bind(null,o.push.bind(o))})(),t.O(void 0,[466],(()=>t(711)));var a=t.O(void 0,[466],(()=>t(713)));a=t.O(a)})();
|
||||
(()=>{"use strict";var r,e={713:()=>{},359:()=>{}},o={};function t(r){var a=o[r];if(void 0!==a)return a.exports;var n=o[r]={exports:{}};return e[r](n,n.exports,t),n.exports}t.m=e,r=[],t.O=(e,o,a,n)=>{if(!o){var i=1/0;for(f=0;f<r.length;f++){for(var[o,a,n]=r[f],p=!0,v=0;v<o.length;v++)(!1&n||i>=n)&&Object.keys(t.O).every((r=>t.O[r](o[v])))?o.splice(v--,1):(p=!1,n<i&&(i=n));if(p){r.splice(f--,1);var s=a();void 0!==s&&(e=s)}}return e}n=n||0;for(var f=r.length;f>0&&r[f-1][2]>n;f--)r[f]=r[f-1];r[f]=[o,a,n]},t.o=(r,e)=>Object.prototype.hasOwnProperty.call(r,e),(()=>{var r={364:0,416:0};t.O.j=e=>0===r[e];var e=(e,o)=>{var a,n,[i,p,v]=o,s=0;if(i.some((e=>0!==r[e]))){for(a in p)t.o(p,a)&&(t.m[a]=p[a]);if(v)var f=v(t)}for(e&&e(o);s<i.length;s++)n=i[s],t.o(r,n)&&r[n]&&r[n][0](),r[n]=0;return t.O(f)},o=self.webpackChunkapp=self.webpackChunkapp||[];o.forEach(e.bind(null,0)),o.push=e.bind(null,o.push.bind(o))})(),t.O(void 0,[416],(()=>t(359)));var a=t.O(void 0,[416],(()=>t(713)));a=t.O(a)})();
|
||||
@@ -1 +1 @@
|
||||
(()=>{"use strict";var r,e={930:()=>{},711:()=>{}},o={};function t(r){var a=o[r];if(void 0!==a)return a.exports;var n=o[r]={exports:{}};return e[r](n,n.exports,t),n.exports}t.m=e,r=[],t.O=(e,o,a,n)=>{if(!o){var i=1/0;for(f=0;f<r.length;f++){for(var[o,a,n]=r[f],p=!0,v=0;v<o.length;v++)(!1&n||i>=n)&&Object.keys(t.O).every((r=>t.O[r](o[v])))?o.splice(v--,1):(p=!1,n<i&&(i=n));if(p){r.splice(f--,1);var s=a();void 0!==s&&(e=s)}}return e}n=n||0;for(var f=r.length;f>0&&r[f-1][2]>n;f--)r[f]=r[f-1];r[f]=[o,a,n]},t.o=(r,e)=>Object.prototype.hasOwnProperty.call(r,e),(()=>{var r={607:0,466:0};t.O.j=e=>0===r[e];var e=(e,o)=>{var a,n,[i,p,v]=o,s=0;if(i.some((e=>0!==r[e]))){for(a in p)t.o(p,a)&&(t.m[a]=p[a]);if(v)var f=v(t)}for(e&&e(o);s<i.length;s++)n=i[s],t.o(r,n)&&r[n]&&r[n][0](),r[n]=0;return t.O(f)},o=self.webpackChunkapp=self.webpackChunkapp||[];o.forEach(e.bind(null,0)),o.push=e.bind(null,o.push.bind(o))})(),t.O(void 0,[466],(()=>t(711)));var a=t.O(void 0,[466],(()=>t(930)));a=t.O(a)})();
|
||||
(()=>{"use strict";var r,e={930:()=>{},359:()=>{}},o={};function t(r){var a=o[r];if(void 0!==a)return a.exports;var n=o[r]={exports:{}};return e[r](n,n.exports,t),n.exports}t.m=e,r=[],t.O=(e,o,a,n)=>{if(!o){var i=1/0;for(f=0;f<r.length;f++){for(var[o,a,n]=r[f],p=!0,v=0;v<o.length;v++)(!1&n||i>=n)&&Object.keys(t.O).every((r=>t.O[r](o[v])))?o.splice(v--,1):(p=!1,n<i&&(i=n));if(p){r.splice(f--,1);var s=a();void 0!==s&&(e=s)}}return e}n=n||0;for(var f=r.length;f>0&&r[f-1][2]>n;f--)r[f]=r[f-1];r[f]=[o,a,n]},t.o=(r,e)=>Object.prototype.hasOwnProperty.call(r,e),(()=>{var r={607:0,416:0};t.O.j=e=>0===r[e];var e=(e,o)=>{var a,n,[i,p,v]=o,s=0;if(i.some((e=>0!==r[e]))){for(a in p)t.o(p,a)&&(t.m[a]=p[a]);if(v)var f=v(t)}for(e&&e(o);s<i.length;s++)n=i[s],t.o(r,n)&&r[n]&&r[n][0](),r[n]=0;return t.O(f)},o=self.webpackChunkapp=self.webpackChunkapp||[];o.forEach(e.bind(null,0)),o.push=e.bind(null,o.push.bind(o))})(),t.O(void 0,[416],(()=>t(359)));var a=t.O(void 0,[416],(()=>t(930)));a=t.O(a)})();
|
||||
2
static/dist/js/main.bundle.js
vendored
2
static/dist/js/main.bundle.js
vendored
File diff suppressed because one or more lines are too long
1
static/dist/js/store_home.bundle.js
vendored
1
static/dist/js/store_home.bundle.js
vendored
@@ -1 +0,0 @@
|
||||
(()=>{"use strict";var r,e={969:()=>{},711:()=>{}},o={};function t(r){var a=o[r];if(void 0!==a)return a.exports;var n=o[r]={exports:{}};return e[r](n,n.exports,t),n.exports}t.m=e,r=[],t.O=(e,o,a,n)=>{if(!o){var i=1/0;for(f=0;f<r.length;f++){for(var[o,a,n]=r[f],p=!0,v=0;v<o.length;v++)(!1&n||i>=n)&&Object.keys(t.O).every((r=>t.O[r](o[v])))?o.splice(v--,1):(p=!1,n<i&&(i=n));if(p){r.splice(f--,1);var s=a();void 0!==s&&(e=s)}}return e}n=n||0;for(var f=r.length;f>0&&r[f-1][2]>n;f--)r[f]=r[f-1];r[f]=[o,a,n]},t.o=(r,e)=>Object.prototype.hasOwnProperty.call(r,e),(()=>{var r={568:0,466:0};t.O.j=e=>0===r[e];var e=(e,o)=>{var a,n,[i,p,v]=o,s=0;if(i.some((e=>0!==r[e]))){for(a in p)t.o(p,a)&&(t.m[a]=p[a]);if(v)var f=v(t)}for(e&&e(o);s<i.length;s++)n=i[s],t.o(r,n)&&r[n]&&r[n][0](),r[n]=0;return t.O(f)},o=self.webpackChunkapp=self.webpackChunkapp||[];o.forEach(e.bind(null,0)),o.push=e.bind(null,o.push.bind(o))})(),t.O(void 0,[466],(()=>t(711)));var a=t.O(void 0,[466],(()=>t(969)));a=t.O(a)})();
|
||||
@@ -1 +0,0 @@
|
||||
(()=>{"use strict";var r,e={612:()=>{},711:()=>{}},o={};function t(r){var a=o[r];if(void 0!==a)return a.exports;var n=o[r]={exports:{}};return e[r](n,n.exports,t),n.exports}t.m=e,r=[],t.O=(e,o,a,n)=>{if(!o){var i=1/0;for(f=0;f<r.length;f++){for(var[o,a,n]=r[f],p=!0,v=0;v<o.length;v++)(!1&n||i>=n)&&Object.keys(t.O).every((r=>t.O[r](o[v])))?o.splice(v--,1):(p=!1,n<i&&(i=n));if(p){r.splice(f--,1);var s=a();void 0!==s&&(e=s)}}return e}n=n||0;for(var f=r.length;f>0&&r[f-1][2]>n;f--)r[f]=r[f-1];r[f]=[o,a,n]},t.o=(r,e)=>Object.prototype.hasOwnProperty.call(r,e),(()=>{var r={953:0,466:0};t.O.j=e=>0===r[e];var e=(e,o)=>{var a,n,[i,p,v]=o,s=0;if(i.some((e=>0!==r[e]))){for(a in p)t.o(p,a)&&(t.m[a]=p[a]);if(v)var f=v(t)}for(e&&e(o);s<i.length;s++)n=i[s],t.o(r,n)&&r[n]&&r[n][0](),r[n]=0;return t.O(f)},o=self.webpackChunkapp=self.webpackChunkapp||[];o.forEach(e.bind(null,0)),o.push=e.bind(null,o.push.bind(o))})(),t.O(void 0,[466],(()=>t(711)));var a=t.O(void 0,[466],(()=>t(612)));a=t.O(a)})();
|
||||
@@ -1 +0,0 @@
|
||||
(()=>{"use strict";var r,e={235:()=>{},711:()=>{}},o={};function t(r){var a=o[r];if(void 0!==a)return a.exports;var n=o[r]={exports:{}};return e[r](n,n.exports,t),n.exports}t.m=e,r=[],t.O=(e,o,a,n)=>{if(!o){var i=1/0;for(f=0;f<r.length;f++){for(var[o,a,n]=r[f],p=!0,v=0;v<o.length;v++)(!1&n||i>=n)&&Object.keys(t.O).every((r=>t.O[r](o[v])))?o.splice(v--,1):(p=!1,n<i&&(i=n));if(p){r.splice(f--,1);var s=a();void 0!==s&&(e=s)}}return e}n=n||0;for(var f=r.length;f>0&&r[f-1][2]>n;f--)r[f]=r[f-1];r[f]=[o,a,n]},t.o=(r,e)=>Object.prototype.hasOwnProperty.call(r,e),(()=>{var r={710:0,466:0};t.O.j=e=>0===r[e];var e=(e,o)=>{var a,n,[i,p,v]=o,s=0;if(i.some((e=>0!==r[e]))){for(a in p)t.o(p,a)&&(t.m[a]=p[a]);if(v)var f=v(t)}for(e&&e(o);s<i.length;s++)n=i[s],t.o(r,n)&&r[n]&&r[n][0](),r[n]=0;return t.O(f)},o=self.webpackChunkapp=self.webpackChunkapp||[];o.forEach(e.bind(null,0)),o.push=e.bind(null,o.push.bind(o))})(),t.O(void 0,[466],(()=>t(711)));var a=t.O(void 0,[466],(()=>t(235)));a=t.O(a)})();
|
||||
1
static/dist/js/store_stock_items.bundle.js
vendored
1
static/dist/js/store_stock_items.bundle.js
vendored
@@ -1 +0,0 @@
|
||||
(()=>{"use strict";var r,e={813:()=>{},711:()=>{}},o={};function t(r){var a=o[r];if(void 0!==a)return a.exports;var n=o[r]={exports:{}};return e[r](n,n.exports,t),n.exports}t.m=e,r=[],t.O=(e,o,a,n)=>{if(!o){var i=1/0;for(f=0;f<r.length;f++){for(var[o,a,n]=r[f],p=!0,v=0;v<o.length;v++)(!1&n||i>=n)&&Object.keys(t.O).every((r=>t.O[r](o[v])))?o.splice(v--,1):(p=!1,n<i&&(i=n));if(p){r.splice(f--,1);var s=a();void 0!==s&&(e=s)}}return e}n=n||0;for(var f=r.length;f>0&&r[f-1][2]>n;f--)r[f]=r[f-1];r[f]=[o,a,n]},t.o=(r,e)=>Object.prototype.hasOwnProperty.call(r,e),(()=>{var r={4:0,466:0};t.O.j=e=>0===r[e];var e=(e,o)=>{var a,n,[i,p,v]=o,s=0;if(i.some((e=>0!==r[e]))){for(a in p)t.o(p,a)&&(t.m[a]=p[a]);if(v)var f=v(t)}for(e&&e(o);s<i.length;s++)n=i[s],t.o(r,n)&&r[n]&&r[n][0](),r[n]=0;return t.O(f)},o=self.webpackChunkapp=self.webpackChunkapp||[];o.forEach(e.bind(null,0)),o.push=e.bind(null,o.push.bind(o))})(),t.O(void 0,[466],(()=>t(711)));var a=t.O(void 0,[466],(()=>t(813)));a=t.O(a)})();
|
||||
2
static/dist/page_core_home.chunk.js
vendored
2
static/dist/page_core_home.chunk.js
vendored
File diff suppressed because one or more lines are too long
2
static/dist/page_privacy_policy.chunk.js
vendored
2
static/dist/page_privacy_policy.chunk.js
vendored
File diff suppressed because one or more lines are too long
@@ -91,7 +91,7 @@ function convertForm2JSON(elemForm) {
|
||||
/*
|
||||
console.log('field name: ' + field.name);
|
||||
console.log('field value: ' + field.value);
|
||||
console.log('field currentval: ' + getElementCurrentValue(field));
|
||||
console.log('field currentval: ' + getElementValueCurrent(field));
|
||||
*/
|
||||
});
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import DOM from './dom.js';
|
||||
export default class API {
|
||||
|
||||
static getCsrfToken() {
|
||||
// return document.querySelectorAll('meta[name=' + nameCSRFToken + ']').attr('content');
|
||||
// return document.querySelectorAll('meta[name=' + nameCSRFToken + ']').getAttribute('content');
|
||||
return document.querySelector(idCSRFToken).getAttribute('content');
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ export default class API {
|
||||
}
|
||||
|
||||
// store
|
||||
// categories
|
||||
// product categories
|
||||
static async getCategories() {
|
||||
return await API.request(hashGetStoreProductCategory);
|
||||
}
|
||||
@@ -90,10 +90,25 @@ export default class API {
|
||||
static async saveCategories(categories, formFilters, comment) {
|
||||
let dataRequest = {};
|
||||
dataRequest[flagFormFilters] = DOM.convertForm2JSON(formFilters);
|
||||
dataRequest[flagCategory] = categories;
|
||||
dataRequest[flagProductCategory] = categories;
|
||||
dataRequest[flagComment] = comment;
|
||||
return await API.request(hashSaveStoreProductCategory, 'POST', dataRequest);
|
||||
}
|
||||
|
||||
// product permutations
|
||||
static async getProductPermutations() {
|
||||
return await API.request(hashGetStoreProductPermutation);
|
||||
}
|
||||
static async getProductPermutationsByFilters(filtersJson) {
|
||||
API.goToHash(hashPageStoreProductPermutations, filtersJson);
|
||||
}
|
||||
static async saveProductPermutations(permutations, formFilters, comment) {
|
||||
let dataRequest = {};
|
||||
dataRequest[flagFormFilters] = DOM.convertForm2JSON(formFilters);
|
||||
dataRequest[flagProductPermutation] = permutations;
|
||||
dataRequest[flagComment] = comment;
|
||||
return await API.request(hashSaveStoreProductPermutation, 'POST', dataRequest);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/*
|
||||
// Bundle css imports
|
||||
import '../css/lib/reset.css';
|
||||
import '../css/lib/typography.css';
|
||||
@@ -6,6 +7,7 @@ import '../css/lib/utils.css';
|
||||
|
||||
import '../css/layouts/header.css';
|
||||
import '../css/layouts/footer.css';
|
||||
import '../css/layouts/table-main.css'
|
||||
|
||||
import '../css/components/button.css';
|
||||
import '../css/components/card.css';
|
||||
@@ -16,7 +18,7 @@ import '../css/components/navigation.css';
|
||||
import '../css/components/overlay.css';
|
||||
|
||||
import '../css/sections/store.css';
|
||||
|
||||
*/
|
||||
|
||||
|
||||
// Main entry point for the application
|
||||
@@ -34,7 +36,6 @@ class App {
|
||||
}
|
||||
|
||||
initialize() {
|
||||
console.log('Initializing application...');
|
||||
this.setupEventListeners();
|
||||
this.start();
|
||||
}
|
||||
@@ -51,13 +52,11 @@ class App {
|
||||
}
|
||||
|
||||
start() {
|
||||
console.log('Starting application...');
|
||||
// Additional startup logic
|
||||
this.initPageCurrent();
|
||||
}
|
||||
|
||||
initPageCurrent() {
|
||||
console.log("initPageCurrent");
|
||||
/*
|
||||
_pageCurrent = Router.getPageCurrent();
|
||||
_pageCurrent.initialize();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
import Validation from "./lib/validation.js";
|
||||
import Validation from "../../../lib/validation.js";
|
||||
|
||||
|
||||
// Date picker inputs
|
||||
@@ -99,7 +99,7 @@ function turnInputIntoDatePicker(input, notFuture, notPast, exceptionValueArray)
|
||||
input.addEventListener('contextmenu', function() { this.datepicker('hide'); });
|
||||
|
||||
// Disable autocomplete suggestions appearing when clicking on input
|
||||
input.attr('autocomplete', 'off');
|
||||
input.getAttribute('autocomplete', 'off');
|
||||
}
|
||||
|
||||
function setDatePickerDate(input, objDate) {
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
function handleSelectCollapse(elementSelect) {
|
||||
let optionSelected = document.querySelectorAll(elementSelect).querySelector('option:selected');
|
||||
optionSelected.text(optionSelected.attr(attrTextCollapsed));
|
||||
optionSelected.text(optionSelected.getAttribute(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));
|
||||
optionSelected.text(optionSelected.getAttribute(attrTextExpanded));
|
||||
console.log('expanded: ', optionSelected.text());
|
||||
optionSelected.classList.remove(flagCollapsed);
|
||||
optionSelected.classList.add(flagExpanded);
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
import Validation from "./lib/validation.js";
|
||||
import Validation from "../../../lib/validation.js";
|
||||
|
||||
export default class TextArea {
|
||||
removeBlankTextAreaLines(textarea) {
|
||||
@@ -25,7 +25,7 @@ export default class TextArea {
|
||||
|
||||
// Clear style height and set rows = 1
|
||||
elTextarea.style.removeProperty('height');
|
||||
textarea.attr('rows', 1);
|
||||
textarea.getAttribute('rows', 1);
|
||||
|
||||
const paddingTop = parseCSSPropertyToFloat(textarea, 'padding-top');
|
||||
const paddingBottom= parseCSSPropertyToFloat(textarea, 'padding-bottom');
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
import Validation from "./lib/validation.js";
|
||||
import Validation from "../../lib/validation.js";
|
||||
|
||||
|
||||
export default class Table {
|
||||
26
static/js/components/common/temporary/overlay_confirm.js
Normal file
26
static/js/components/common/temporary/overlay_confirm.js
Normal file
@@ -0,0 +1,26 @@
|
||||
|
||||
import Events from "../../../lib/events.js";
|
||||
|
||||
export default class OverlayConfirm {
|
||||
static hookup(callbackSuccess) {
|
||||
Events.initialiseEventHandler(idOverlayConfirm + ' button.' + flagCancel, flagInitialised, (buttonCancel) => {
|
||||
buttonCancel.addEventListener('click', () => {
|
||||
let overlay = document.querySelector(idOverlayConfirm);
|
||||
overlay.style.visibility = 'hidden';
|
||||
});
|
||||
});
|
||||
Events.initialiseEventHandler(idOverlayConfirm + ' button.' + flagSubmit, flagInitialised, (buttonConfirm) => {
|
||||
buttonConfirm.addEventListener('click', () => {
|
||||
let overlay = document.querySelector(idOverlayConfirm);
|
||||
let textarea = overlay.querySelector('textarea');
|
||||
overlay.style.visibility = 'hidden';
|
||||
callbackSuccess(textarea.value);
|
||||
});
|
||||
});
|
||||
}
|
||||
static show() {
|
||||
let overlay = document.querySelector(idOverlayConfirm);
|
||||
overlay.classList.remove(flagCollapsed);
|
||||
overlay.style.visibility = 'visible';
|
||||
}
|
||||
}
|
||||
19
static/js/components/common/temporary/overlay_error.js
Normal file
19
static/js/components/common/temporary/overlay_error.js
Normal file
@@ -0,0 +1,19 @@
|
||||
|
||||
import Events from "../../../lib/events.js";
|
||||
|
||||
export default class OverlayError {
|
||||
static hookup() {
|
||||
Events.initialiseEventHandler(idOverlayError + ' button.' + flagCancel, flagInitialised, (buttonCancel) => {
|
||||
buttonCancel.addEventListener('click', () => {
|
||||
let overlay = document.querySelector(idOverlayError);
|
||||
overlay.style.visibility = 'hidden';
|
||||
});
|
||||
});
|
||||
}
|
||||
static show(msgError) {
|
||||
let overlay = document.querySelector(idOverlayError);
|
||||
let labelError = overlay.querySelector(idLabelError);
|
||||
labelError.innerText = msgError;
|
||||
overlay.style.visibility = 'visible';
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,22 @@ import Validation from "./lib/validation.js";
|
||||
|
||||
// Module for DOM manipulation
|
||||
export default class DOM {
|
||||
static setElementValueCurrent(element, data) {
|
||||
static setElementAttributesValuesCurrentAndPrevious(element, data) {
|
||||
DOM.setElementAttributeValueCurrent(element, data);
|
||||
DOM.setElementAttributeValuePrevious(element, data);
|
||||
}
|
||||
static setElementAttributeValueCurrent(element, data) {
|
||||
element.setAttribute(attrValueCurrent, data);
|
||||
}
|
||||
static setElementAttributeValuePrevious(element, data) {
|
||||
element.setAttribute(attrValuePrevious, data);
|
||||
}
|
||||
static setElementValuesCurrentAndPrevious(element, data) {
|
||||
DOM.setElementValueCurrent(element, data);
|
||||
DOM.setElementAttributeValuePrevious(element, data);
|
||||
}
|
||||
static setElementValueCurrent(element, data) {
|
||||
DOM.setElementAttributeValueCurrent(element, data);
|
||||
if (element.type === "checkbox") {
|
||||
element.checked = data;
|
||||
}
|
||||
@@ -15,8 +29,10 @@ export default class DOM {
|
||||
element.textContent = data;
|
||||
}
|
||||
}
|
||||
static setElementValuePrevious(element, data) {
|
||||
element.setAttribute(attrValuePrevious, data);
|
||||
static setElementValueCurrentIfEmpty(element, data) {
|
||||
if (Validation.isEmpty(DOM.getElementValueCurrent(element))) {
|
||||
DOM.setElementValueCurrent(element, data);
|
||||
}
|
||||
}
|
||||
static getCellFromElement(element) {
|
||||
return element.closest('td');
|
||||
@@ -48,22 +64,33 @@ export default class DOM {
|
||||
}
|
||||
static getHashPageCurrent() {
|
||||
const hashPageCurrent = document.body.dataset.page;
|
||||
console.log("hashPageCurrent: " + hashPageCurrent);
|
||||
return hashPageCurrent;
|
||||
}
|
||||
static isElementDirty(element) {
|
||||
static updateAndCheckIsElementDirty(element) {
|
||||
element.setAttribute(attrValueCurrent, DOM.getElementValueCurrent(element));
|
||||
return DOM.isElementDirty(element);
|
||||
}
|
||||
static isElementDirty(element) {
|
||||
let isDirty = element.getAttribute(attrValuePrevious) != element.getAttribute(attrValueCurrent);
|
||||
DOM.handleDirtyElement(element, isDirty);
|
||||
return isDirty;
|
||||
}
|
||||
static handleDirtyElement(element, isDirty) {
|
||||
if (isDirty) {
|
||||
element.classList.add(flagDirty);
|
||||
DOM.toggleElementHasClassnameFlag(element, isDirty, flagDirty);
|
||||
}
|
||||
static toggleElementHasClassnameFlag(element, elementHasFlag, flag) {
|
||||
let elementAlreadyHasFlag = element.classList.contains(flag);
|
||||
if (elementHasFlag == elementAlreadyHasFlag) return;
|
||||
if (elementHasFlag) {
|
||||
element.classList.add(flag);
|
||||
} else {
|
||||
element.classList.remove(flagDirty);
|
||||
element.classList.remove(flag);
|
||||
}
|
||||
}
|
||||
static hasDirtyChildrenContainer(container) {
|
||||
if (container == null) return false;
|
||||
return container.querySelector('.' + flagDirty) != null;
|
||||
}
|
||||
static getElementValueCurrent(element) {
|
||||
let returnVal = '';
|
||||
|
||||
@@ -89,8 +116,14 @@ export default class DOM {
|
||||
|
||||
return returnVal;
|
||||
}
|
||||
static isTableElementDirty(element) {
|
||||
let isDirty = DOM.isElementDirty(element);
|
||||
static getElementAttributeValueCurrent(element) {
|
||||
return element.getAttribute(attrValueCurrent);
|
||||
}
|
||||
static getElementAttributeValuePrevious(element) {
|
||||
return element.getAttribute(attrValuePrevious);
|
||||
}
|
||||
static updateAndCheckIsTableElementDirty(element) {
|
||||
let isDirty = DOM.updateAndCheckIsElementDirty(element);
|
||||
let cell = DOM.getCellFromElement(element);
|
||||
if (isDirty) {
|
||||
cell.classList.add(flagDirty);
|
||||
@@ -110,11 +143,11 @@ export default class DOM {
|
||||
/* non-static method on page object to use
|
||||
static handleChangeElement(element) {}
|
||||
*/
|
||||
scrollToElement(parent, element) {
|
||||
static scrollToElement(parent, element) {
|
||||
// REQUIRED: parent has scroll-bar
|
||||
parent.scrollTop(parent.scrollTop() + (element.offset().top - parent.offset().top));
|
||||
}
|
||||
isElementInContainer(container, element) {
|
||||
static isElementInContainer(container, element) {
|
||||
|
||||
if (typeof jQuery === 'function') {
|
||||
if (container instanceof jQuery) container = container[0];
|
||||
@@ -131,7 +164,34 @@ export default class DOM {
|
||||
((elementBounds.left + elementBounds.width) <= (containerBounds.left + containerBounds.width))
|
||||
);
|
||||
}
|
||||
alertError(errorType, errorText) {
|
||||
static alertError(errorType, errorText) {
|
||||
alert(errorType + '\n' + errorText);
|
||||
}
|
||||
static createOptionUnselectedProductVariation() {
|
||||
return {
|
||||
[flagProductVariationType]: {
|
||||
[flagNameAttrOptionText]: [flagName],
|
||||
[flagNameAttrOptionValue]: [attrIdProductVariationType],
|
||||
[flagName]: 'Select Variation Type',
|
||||
[attrIdProductVariationType]: 0,
|
||||
},
|
||||
[flagProductVariation]: {
|
||||
[flagNameAttrOptionText]: [flagName],
|
||||
[flagNameAttrOptionValue]: [attrIdProductVariation],
|
||||
[flagName]: 'Select Variation',
|
||||
[attrIdProductVariation]: 0,
|
||||
},
|
||||
};
|
||||
}
|
||||
static createOption(optionJson) {
|
||||
if (Validation.isEmpty(optionJson)) optionJson = {
|
||||
text: 'Select',
|
||||
value: 0,
|
||||
};
|
||||
let option = document.createElement('option');
|
||||
option.value = optionJson.value;
|
||||
option.textContent = optionJson.text;
|
||||
option.selected = optionJson.selected;
|
||||
return option;
|
||||
}
|
||||
}
|
||||
|
||||
24
static/js/lib/business_objects.js
Normal file
24
static/js/lib/business_objects.js
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
|
||||
export default class BusinessObjects {
|
||||
static getOptionJsonFromObjectJsonAndKeys(objectJson, keyText, keyValue, valueSelected = null) {
|
||||
return {
|
||||
text: objectJson[keyText],
|
||||
value: objectJson[keyValue],
|
||||
selected: (objectJson[keyValue] == valueSelected),
|
||||
};
|
||||
}
|
||||
static getOptionJsonFromObjectJson(objectJson, valueSelected = null) {
|
||||
let keyText = objectJson[flagNameAttrOptionText];
|
||||
let keyValue = objectJson[flagNameAttrOptionValue];
|
||||
console.log({objectJson, keyText, keyValue});
|
||||
return BusinessObjects.getOptionJsonFromObjectJsonAndKeys(objectJson, keyText, keyValue, valueSelected);
|
||||
}
|
||||
/*
|
||||
static getOptionJsonFromProductPermutation(permutation) {
|
||||
return {
|
||||
text: permutation
|
||||
};
|
||||
}
|
||||
*/
|
||||
}
|
||||
@@ -7,4 +7,13 @@ function $(selector) {
|
||||
function $$(selector) {
|
||||
return document.querySelectorAll(selector);
|
||||
}
|
||||
*/
|
||||
*/
|
||||
export default class Utils {
|
||||
static getListFromDict(dict) {
|
||||
let list = [];
|
||||
for (let key in dict) {
|
||||
list.push(dict[key]);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,13 @@
|
||||
|
||||
import BusinessObjects from "../lib/business_objects.js";
|
||||
import Events from "../lib/events.js";
|
||||
import LocalStorage from "../lib/local_storage.js";
|
||||
import API from "../api.js";
|
||||
import DOM from "../dom.js";
|
||||
|
||||
import OverlayConfirm from "../components/common/temporary/overlay_confirm.js";
|
||||
import OverlayError from "../components/common/temporary/overlay_error.js";
|
||||
|
||||
export default class BasePage {
|
||||
constructor(router) {
|
||||
if (!router) {
|
||||
@@ -45,182 +49,117 @@ export default class BasePage {
|
||||
|
||||
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);
|
||||
// console.log('count nav options: ', countOptions);
|
||||
// overlayHamburger.css('height', (countOptions * 27) + 'px');
|
||||
/* end of can be removed */
|
||||
|
||||
Events.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.hookupEventHandler("click", idButtonHamburger, (event, element) => {
|
||||
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();
|
||||
this.hookupButtonsNavHome();
|
||||
this.hookupButtonsNavServices();
|
||||
this.hookupButtonsNavContact();
|
||||
this.hookupButtonsNavUserAccount();
|
||||
this.hookupButtonsNavUserLogout();
|
||||
this.hookupButtonsNavUserLogin();
|
||||
this.hookupButtonsNavStoreHome();
|
||||
this.hookupButtonsNavStoreProductPermutations();
|
||||
this.hookupButtonsNavStoreStockItems();
|
||||
this.hookupButtonsNavAdminHome();
|
||||
}
|
||||
hookupButtonNavHome() {
|
||||
Events.initialiseEventHandler('.' + flagNavHome, flagInitialised, (navigator) => {
|
||||
navigator.addEventListener("click", (event) => {
|
||||
hookupEventHandler(eventType, selector, callback) {
|
||||
Events.initialiseEventHandler(selector, flagInitialised, (element) => {
|
||||
element.addEventListener(eventType, (event) => {
|
||||
event.stopPropagation();
|
||||
this.router.navigateToHash(hashPageHome);
|
||||
callback(event, element);
|
||||
});
|
||||
});
|
||||
}
|
||||
hookupButtonNavServices() {
|
||||
Events.initialiseEventHandler('.' + flagNavServices, flagInitialised, (navigator) => {
|
||||
navigator.addEventListener("click", (event) => {
|
||||
event.stopPropagation();
|
||||
console.log('going to services page');
|
||||
this.router.navigateToHash(hashPageServices);
|
||||
hookupButtonsNavHome() {
|
||||
this.hookupButtonsNav('.' + flagNavHome, hashPageHome);
|
||||
}
|
||||
hookupButtonsNav(buttonSelector, hashPageNav) {
|
||||
this.hookupEventHandler("click", buttonSelector, (event, button) => {
|
||||
this.router.navigateToHash(hashPageNav);
|
||||
});
|
||||
}
|
||||
hookupButtonsNavServices() {
|
||||
this.hookupButtonsNav('.' + flagNavServices, hashPageServices);
|
||||
}
|
||||
hookupButtonsNavContact() {
|
||||
this.hookupButtonsNav('.' + flagNavContact, hashPageContact);
|
||||
}
|
||||
hookupButtonsNavUserAccount() {
|
||||
this.hookupButtonsNav('.' + flagNavUserAccount, hashPageUserAccount);
|
||||
}
|
||||
hookupButtonsNavUserLogout() {
|
||||
this.hookupButtonsNav('.' + flagNavUserLogout, hashPageUserLogout);
|
||||
}
|
||||
hookupButtonsNavUserLogin() {
|
||||
this.hookupEventHandler("click", '.' + flagNavUserLogin, (event, navigator) => {
|
||||
event.stopPropagation();
|
||||
// this.router.navigateToHash(hashPageUserLogin);
|
||||
/*
|
||||
let dataRequest = {};
|
||||
dataRequest[keyCallback] = hashPageCurrent;
|
||||
console.log('sending data to user login controller: ');
|
||||
console.log(dataRequest);
|
||||
*/
|
||||
// let page = this;
|
||||
API.loginUser()
|
||||
.then((response) => {
|
||||
if (response.Success) {
|
||||
this.router.navigateToUrl(response[keyCallback], null, false); // window.app.
|
||||
} else {
|
||||
DOM.alertError("Error", response.Message);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
hookupButtonNavContact() {
|
||||
Events.initialiseEventHandler('.' + flagNavContact, flagInitialised, (navigator) => {
|
||||
navigator.addEventListener("click", (event) => {
|
||||
event.stopPropagation();
|
||||
this.router.navigateToHash(hashPageContact);
|
||||
});
|
||||
});
|
||||
hookupButtonsNavStoreHome() {
|
||||
this.hookupButtonsNav('.' + flagNavStoreHome, hashPageStoreHome);
|
||||
}
|
||||
hookupButtonNavUserAccount() {
|
||||
Events.initialiseEventHandler('.' + flagNavUserAccount, flagInitialised, (navigator) => {
|
||||
navigator.addEventListener("click", (event) => {
|
||||
event.stopPropagation();
|
||||
this.router.navigateToHash(hashPageUserAccount);
|
||||
});
|
||||
});
|
||||
hookupButtonsNavStoreProductCategories() {
|
||||
this.hookupButtonsNav('.' + flagNavStoreProductCategories, hashPageStoreProductCategories);
|
||||
}
|
||||
hookupButtonNavUserLogout() {
|
||||
Events.initialiseEventHandler('.' + flagNavUserLogout, flagInitialised, (navigator) => {
|
||||
navigator.addEventListener("click", (event) => {
|
||||
event.stopPropagation();
|
||||
this.router.navigateToHash(hashPageUserLogout);
|
||||
});
|
||||
});
|
||||
hookupButtonsNavStoreProducts() {
|
||||
this.hookupButtonsNav('.' + flagNavStoreProducts, hashPageStoreProducts);
|
||||
}
|
||||
hookupButtonNavUserLogin() {
|
||||
Events.initialiseEventHandler('.' + flagNavUserLogin, flagInitialised, (navigator) => {
|
||||
navigator.addEventListener("click", (event) => {
|
||||
event.stopPropagation();
|
||||
// this.router.navigateToHash(hashPageUserLogin);
|
||||
/*
|
||||
let dataRequest = {};
|
||||
dataRequest[keyCallback] = hashPageCurrent;
|
||||
console.log('sending data to user login controller: ');
|
||||
console.log(dataRequest);
|
||||
*/
|
||||
// let page = this;
|
||||
API.loginUser()
|
||||
.then((response) => {
|
||||
if (response.Success) {
|
||||
this.router.navigateToUrl(response[keyCallback], null, false); // window.app.
|
||||
} else {
|
||||
DOM.alertError("Error", response.Message);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
hookupButtonsNavStoreProductPermutations() {
|
||||
this.hookupButtonsNav('.' + flagNavStoreProductPermutations, hashPageStoreProductPermutations);
|
||||
}
|
||||
hookupButtonNavStoreHome() {
|
||||
Events.initialiseEventHandler('.' + flagNavStoreHome, flagInitialised, (navigator) => {
|
||||
navigator.addEventListener("click", (event) => {
|
||||
event.stopPropagation();
|
||||
this.router.navigateToHash(hashPageStoreHome);
|
||||
});
|
||||
});
|
||||
hookupButtonsNavStoreProductPrices() {
|
||||
this.hookupButtonsNav('.' + flagNavStoreProductPrices, hashPageStoreProductPrices);
|
||||
}
|
||||
hookupButtonNavStoreProductCategories() {
|
||||
Events.initialiseEventHandler('.' + flagNavStoreProductCategories, flagInitialised, (navigator) => {
|
||||
navigator.addEventListener("click", (event) => {
|
||||
event.stopPropagation();
|
||||
this.router.navigateToHash(hashPageStoreProductCategories);
|
||||
});
|
||||
});
|
||||
hookupButtonsNavStoreProductVariations() {
|
||||
this.hookupButtonsNav('.' + flagNavStoreProductVariations, hashPageStoreProductVariations);
|
||||
}
|
||||
hookupButtonNavStoreProducts() {
|
||||
Events.initialiseEventHandler('.' + flagNavStoreProducts, flagInitialised, (navigator) => {
|
||||
navigator.addEventListener("click", (event) => {
|
||||
event.stopPropagation();
|
||||
this.router.navigateToHash(hashPageStoreProducts);
|
||||
});
|
||||
});
|
||||
hookupButtonsNavStoreStockItems() {
|
||||
this.hookupButtonsNav('.' + flagNavStoreStockItems, hashPageStoreStockItems);
|
||||
}
|
||||
hookupButtonNavStoreProductPermutations() {
|
||||
Events.initialiseEventHandler('.' + flagNavStoreProductPermutations, flagInitialised, (navigator) => {
|
||||
navigator.addEventListener("click", (event) => {
|
||||
event.stopPropagation();
|
||||
this.router.navigateToHash(hashPageStoreProductPermutations);
|
||||
});
|
||||
});
|
||||
}
|
||||
hookupButtonNavStoreProductPrices() {
|
||||
Events.initialiseEventHandler('.' + flagNavStoreProductPrices, flagInitialised, (navigator) => {
|
||||
navigator.addEventListener("click", (event) => {
|
||||
event.stopPropagation();
|
||||
this.router.navigateToHash(hashPageStoreProductPrices);
|
||||
});
|
||||
});
|
||||
}
|
||||
hookupButtonNavStoreProductVariations() {
|
||||
Events.initialiseEventHandler('.' + flagNavStoreProductVariations, flagInitialised, (navigator) => {
|
||||
navigator.addEventListener("click", (event) => {
|
||||
event.stopPropagation();
|
||||
this.router.navigateToHash(hashPageStoreProductVariations);
|
||||
});
|
||||
});
|
||||
}
|
||||
hookupButtonNavStoreStockItems() {
|
||||
Events.initialiseEventHandler('.' + flagNavStoreStockItems, flagInitialised, (navigator) => {
|
||||
navigator.addEventListener("click", (event) => {
|
||||
event.stopPropagation();
|
||||
this.router.navigateToHash(hashPageStoreStockItems);
|
||||
});
|
||||
});
|
||||
}
|
||||
hookupButtonNavAdminHome() {
|
||||
Events.initialiseEventHandler('.' + flagNavAdminHome, flagInitialised, (navigator) => {
|
||||
navigator.addEventListener("click", (event) => {
|
||||
event.stopPropagation();
|
||||
this.router.navigateToHash(hashPageAdminHome);
|
||||
});
|
||||
});
|
||||
hookupButtonsNavAdminHome() {
|
||||
this.hookupButtonsNav('.' + flagNavAdminHome, hashPageAdminHome);
|
||||
}
|
||||
|
||||
hookupImagesLogo() {
|
||||
let selectorImagesLogo = "img." + flagImageLogo;
|
||||
Events.initialiseEventHandler(selectorImagesLogo, flagInitialised, (buttonImageLogo) => {
|
||||
buttonImageLogo.addEventListener("click", (event) => {
|
||||
event.stopPropagation();
|
||||
this.router.navigateToHash(hashPageHome);
|
||||
});
|
||||
});
|
||||
this.hookupButtonsNav("img." + flagImageLogo, hashPageHome);
|
||||
}
|
||||
|
||||
hookupOverlayFromId(idOverlay) {
|
||||
Events.initialiseEventHandler(idOverlay, flagInitialised, function(overlay) {
|
||||
overlay.querySelector('button.' + flagClose).addEventListener("click", function(event) {
|
||||
Events.initialiseEventHandler(idOverlay, flagInitialised, (overlay) => {
|
||||
overlay.querySelector('button.' + flagClose).addEventListener("click", (event) => {
|
||||
event.stopPropagation();
|
||||
overlay.css('display', 'none');
|
||||
});
|
||||
@@ -229,17 +168,18 @@ export default class BasePage {
|
||||
|
||||
|
||||
hookupButtonSave() {
|
||||
Events.initialiseEventHandler('form.' + flagFilter + ' button.' + flagSave, flagInitialised, function(button) {
|
||||
button.addEventListener("click", function(event) {
|
||||
Events.initialiseEventHandler('form.' + flagFilter + ' button.' + flagSave, flagInitialised, (button) => {
|
||||
button.addEventListener("click", (event) => {
|
||||
event.stopPropagation();
|
||||
showOverlayConfirm();
|
||||
console.log('saving page: ', this.title);
|
||||
OverlayConfirm.show();
|
||||
});
|
||||
button.classList.add(flagCollapsed);
|
||||
// button.classList.add(flagCollapsed);
|
||||
});
|
||||
}
|
||||
|
||||
hookupVideos() {
|
||||
Events.initialiseEventHandler('video', flagInitialised, function(video) {
|
||||
Events.initialiseEventHandler('video', flagInitialised, (video) => {
|
||||
video.addEventListener("mouseover", videoPlay(video));
|
||||
video.addEventListener("mouseout", videoPause(video));
|
||||
});
|
||||
@@ -252,15 +192,15 @@ export default class BasePage {
|
||||
}
|
||||
}
|
||||
setLocalStoragePage(dataPage) {
|
||||
LocalStorage.setLocalStorage(this.constructor.hash, dataPage);
|
||||
LocalStorage.setLocalStorage(this.hash, dataPage);
|
||||
}
|
||||
getLocalStoragePage() {
|
||||
return LocalStorage.getLocalStorage(this.constructor.hash);
|
||||
return LocalStorage.getLocalStorage(this.hash);
|
||||
}
|
||||
|
||||
toggleShowButtonsSaveCancel(show, buttonSave = null, buttonCancel = null) {
|
||||
if (buttonSave == null) buttonSave = document.querySelector('form.' + flagFilter + ' button.' + flagSave);
|
||||
if (buttonCancel == null) buttonCancel = document.querySelector('form.' + flagFilter + ' button.' + flagCancel);
|
||||
toggleShowButtonsSaveCancel(show) { // , buttonSave = null, buttonCancel = null
|
||||
let buttonSave = document.querySelector('form.' + flagFilter + ' button.' + flagSave);
|
||||
let buttonCancel = document.querySelector('form.' + flagFilter + ' button.' + flagCancel);
|
||||
if (show) {
|
||||
buttonCancel.classList.remove(flagCollapsed);
|
||||
buttonSave.classList.remove(flagCollapsed);
|
||||
@@ -271,7 +211,7 @@ export default class BasePage {
|
||||
}
|
||||
|
||||
static isDirtyFilter(filter) {
|
||||
let isDirty = DOM.isElementDirty(filter);
|
||||
let isDirty = DOM.updateAndCheckIsElementDirty(filter);
|
||||
if (isDirty) document.querySelectorAll(idTableMain + ' tbody tr').remove();
|
||||
return isDirty;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
|
||||
import BusinessObjects from "../lib/business_objects.js";
|
||||
import Events from "../lib/events.js";
|
||||
import LocalStorage from "../lib/local_storage.js";
|
||||
import Validation from "../lib/validation.js";
|
||||
import BasePage from "./base.js";
|
||||
import API from "../api.js";
|
||||
import DOM from "../dom.js";
|
||||
import Utils from "../lib/utils.js";
|
||||
|
||||
import OverlayConfirm from "../components/common/temporary/overlay_confirm.js";
|
||||
import OverlayError from "../components/common/temporary/overlay_error.js";
|
||||
|
||||
export default class TableBasePage extends BasePage {
|
||||
// callFilterTableContent
|
||||
@@ -24,7 +29,6 @@ export default class TableBasePage extends BasePage {
|
||||
this.loadRowTable(null);
|
||||
this.getJsonRow(null);
|
||||
// this.hookupTableMain();
|
||||
this.isDirtyRow(null);
|
||||
this.getTableRecords();
|
||||
this.leave();
|
||||
*/
|
||||
@@ -35,20 +39,25 @@ export default class TableBasePage extends BasePage {
|
||||
this.dragSrcEl = null;
|
||||
this.dragSrcRow = null;
|
||||
|
||||
this.hookupTableCellDdls = this.hookupTableCellDdls.bind(this);
|
||||
}
|
||||
|
||||
initialize(isPopState = false) {
|
||||
if (this.constructor === TableBasePage) {
|
||||
throw new Error("Must implement initialize() method.");
|
||||
}
|
||||
throw new Error("Must implement initialize() method.");
|
||||
}
|
||||
sharedInitialize(isPopState = false, isSinglePageApp = false) {
|
||||
if (!isPopState) {
|
||||
this.sharedInitialize();
|
||||
super.sharedInitialize();
|
||||
this.hookupFilters();
|
||||
this.hookupButtonsAddSaveCancel();
|
||||
this.hookupTableMain();
|
||||
hookupOverlayConfirm(() => {
|
||||
this.leave();
|
||||
this.saveRecordsTableDirty();
|
||||
OverlayConfirm.hookup(() => {
|
||||
if (isSinglePageApp) {
|
||||
this.saveRecordsTableDirtySinglePageApp();
|
||||
}
|
||||
else {
|
||||
this.saveRecordsTableDirty();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
let dataPage = this.getLocalStoragePage();
|
||||
@@ -56,7 +65,7 @@ export default class TableBasePage extends BasePage {
|
||||
let formFilters = this.getFormFilters();
|
||||
let filtersDefault = DOM.convertForm2JSON(formFilters);
|
||||
if (!Validation.areEqualDicts(filters, filtersDefault)) {
|
||||
|
||||
this.callFilterTableContent(filters);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -64,17 +73,19 @@ export default class TableBasePage extends BasePage {
|
||||
if (this.constructor === TableBasePage) {
|
||||
throw new Error("Subclass of TableBasePage must implement method hookupFilters().");
|
||||
}
|
||||
}
|
||||
sharedHookupFilters() {
|
||||
this.hookupButtonApplyFilters();
|
||||
}
|
||||
hookupFilterActive() {
|
||||
Events.initialiseEventHandler(idFormFilters + '.' + flagActive, flagInitialised, (filter) => {
|
||||
filter.addEventListener("change", (event) => {
|
||||
TableBasePage.isDirtyFilter(filter);
|
||||
});
|
||||
});
|
||||
this.hookupFilter(flagActive);
|
||||
}
|
||||
hookupFilter(filterFlag, handler = (event, filter) => { return TableBasePage.isDirtyFilter(filter); }) {
|
||||
let filterSelector = idFormFilters + ' .' + filterFlag;
|
||||
this.hookupEventHandler("change", filterSelector, handler);
|
||||
}
|
||||
static isDirtyFilter(filter) {
|
||||
let isDirty = DOM.isElementDirty(filter);
|
||||
let isDirty = DOM.updateAndCheckIsElementDirty(filter);
|
||||
if (isDirty) {
|
||||
let tbody = document.querySelector(idTableMain + ' tbody');
|
||||
tbody.querySelectorAll('tr').remove();
|
||||
@@ -83,23 +94,16 @@ export default class TableBasePage extends BasePage {
|
||||
return isDirty;
|
||||
}
|
||||
hookupButtonApplyFilters() {
|
||||
Events.initialiseEventHandler(idButtonApplyFilters, flagInitialised, (button) => {
|
||||
button.addEventListener("click", (event) => {
|
||||
event.stopPropagation();
|
||||
this.getAndLoadFilteredTableContent();
|
||||
});
|
||||
this.hookupEventHandler("click", idButtonApplyFilters, (event, button) => {
|
||||
event.stopPropagation();
|
||||
this.getAndLoadFilteredTableContent();
|
||||
});
|
||||
}
|
||||
getAndLoadFilteredTableContent() {
|
||||
let formFilters = this.getFormFilters();
|
||||
let filtersJson = DOM.convertForm2JSON(formFilters);
|
||||
this.leave();
|
||||
this.callFilterTableContent(filtersJson)
|
||||
/*
|
||||
.then(data => {
|
||||
console.log('Table data received:', data);
|
||||
this.callbackLoadTableContent(data);
|
||||
})
|
||||
*/
|
||||
.catch(error => console.error('Error:', error));
|
||||
}
|
||||
getFormFilters() {
|
||||
@@ -122,15 +126,26 @@ export default class TableBasePage extends BasePage {
|
||||
loadRowTable(rowJson) {
|
||||
throw new Error("Subclass of TableBasePage must implement method loadRowTable().");
|
||||
}
|
||||
getAndLoadFilteredTableContentSinglePageApp() {
|
||||
let formFilters = this.getFormFilters();
|
||||
let filtersJson = DOM.convertForm2JSON(formFilters);
|
||||
this.callFilterTableContent(filtersJson)
|
||||
.then(data => {
|
||||
console.log('Table data received:', data);
|
||||
this.callbackLoadTableContent(data);
|
||||
})
|
||||
.catch(error => console.error('Error:', error));
|
||||
}
|
||||
hookupButtonsAddSaveCancel() {
|
||||
this.hookupButtonAddRowTable();
|
||||
this.hookupButtonSave();
|
||||
this.hookupButtonCancel();
|
||||
this.hookupButtonAddRowTable();
|
||||
this.toggleShowButtonsSaveCancel(false);
|
||||
}
|
||||
saveRecordsTableDirty() {
|
||||
let records = this.getTableRecords(true);
|
||||
if (records.length == 0) {
|
||||
showOverlayError('No records to save');
|
||||
OverlayError.show('No records to save');
|
||||
return;
|
||||
}
|
||||
let formElement = this.getFormFilters();
|
||||
@@ -138,12 +153,13 @@ export default class TableBasePage extends BasePage {
|
||||
this.callSaveTableContent(records, formElement, comment)
|
||||
.then(data => {
|
||||
if (data[flagStatus] == flagSuccess) {
|
||||
console.log('Data received:', data);
|
||||
this.callbackLoadTableContent(data);
|
||||
console.log('Records saved!');
|
||||
console.log('Data received:', data);
|
||||
this.getAndLoadFilteredTableContent();
|
||||
}
|
||||
else {
|
||||
showOverlayError(data[flagMessage]);
|
||||
console.log("error: ", data[flagMessage]);
|
||||
OverlayError.show(data[flagMessage]);
|
||||
}
|
||||
})
|
||||
.catch(error => console.error('Error:', error));
|
||||
@@ -162,6 +178,28 @@ export default class TableBasePage extends BasePage {
|
||||
getJsonRow(row) {
|
||||
throw new Error("Subclass of TableBasePage must implement method getJsonRow().");
|
||||
}
|
||||
saveRecordsTableDirtySinglePageApp() {
|
||||
let records = this.getTableRecords(true);
|
||||
if (records.length == 0) {
|
||||
OverlayError.show('No records to save');
|
||||
return;
|
||||
}
|
||||
let formElement = this.getFormFilters();
|
||||
let comment = DOM.getElementValueCurrent(document.querySelector(idTextareaConfirm));
|
||||
this.callSaveTableContent(records, formElement, comment)
|
||||
.then(data => {
|
||||
if (data[flagStatus] == flagSuccess) {
|
||||
console.log('Records saved!');
|
||||
console.log('Data received:', data);
|
||||
this.callbackLoadTableContent(data);
|
||||
}
|
||||
else {
|
||||
console.log("error: ", data[flagMessage]);
|
||||
OverlayError.show(data[flagMessage]);
|
||||
}
|
||||
})
|
||||
.catch(error => console.error('Error:', error));
|
||||
}
|
||||
hookupButtonCancel() {
|
||||
Events.initialiseEventHandler(idFormFilters + ' button.' + flagCancel, flagInitialised, function(button) {
|
||||
button.addEventListener("click", function(event) {
|
||||
@@ -172,32 +210,38 @@ export default class TableBasePage extends BasePage {
|
||||
});
|
||||
}
|
||||
hookupButtonAddRowTable() {
|
||||
Events.initialiseEventHandler(idFormFilters + ' button.' + flagAdd, flagInitialised, (button) => {
|
||||
button.addEventListener("click", (event) => {
|
||||
event.stopPropagation();
|
||||
let tbody = document.querySelector(idTableMain + ' tbody');
|
||||
let row = _rowBlank.cloneNode(true);
|
||||
row.classList.remove(flagInitialised);
|
||||
row.querySelectorAll('.' + flagInitialised).forEach(function(element) {
|
||||
element.classList.remove(flagInitialised);
|
||||
});
|
||||
let newDisplayOrder = parseInt(tbody.querySelector('tr:last-child').querySelector('td.' + flagDisplayOrder + ' .' + flagSlider).getAttribute(attrValueCurrent)) + 1;
|
||||
tbody.appendChild(row);
|
||||
let slider = tbody.querySelector('tr:last-child').querySelector('td.' + flagDisplayOrder + ' .' + flagSlider);
|
||||
if (slider) {
|
||||
slider.setAttribute(attrValueCurrent, newDisplayOrder);
|
||||
slider.setAttribute(attrValuePrevious, newDisplayOrder);
|
||||
}
|
||||
this.hookupTableMain();
|
||||
this.hookupEventHandler("click", idFormFilters + ' button.' + flagAdd, (event, button) => {
|
||||
event.stopPropagation();
|
||||
let tbody = document.querySelector(idTableMain + ' tbody');
|
||||
let row = _rowBlank.cloneNode(true);
|
||||
row.classList.remove(flagInitialised);
|
||||
row.querySelectorAll('.' + flagInitialised).forEach(function(element) {
|
||||
element.classList.remove(flagInitialised);
|
||||
});
|
||||
/* Shared nethods
|
||||
let newDisplayOrder = parseInt(tbody.querySelector('tr:last-child').querySelector('td.' + flagDisplayOrder + ' .' + flagSlider).getAttribute(attrValueCurrent)) + 1;
|
||||
let slider = tbody.querySelector('tr:last-child').querySelector('td.' + flagDisplayOrder + ' .' + flagSlider);
|
||||
if (slider) {
|
||||
slider.setAttribute(attrValueCurrent, newDisplayOrder);
|
||||
slider.setAttribute(attrValuePrevious, newDisplayOrder);
|
||||
}
|
||||
*/
|
||||
this.initialiseRowNew(row);
|
||||
tbody.appendChild(row);
|
||||
this.hookupTableMain();
|
||||
});
|
||||
}
|
||||
initialiseRowNew(row) {
|
||||
throw new Error("Subclass of TableBasePage must implement method initialiseRowNew().");
|
||||
}
|
||||
hookupTableMain() {
|
||||
if (this.constructor === TableBasePage) {
|
||||
throw new Error("Must implement hookupTableMain() method.");
|
||||
}
|
||||
if (_rowBlank == null) {
|
||||
this.cacheRowBlank();
|
||||
Events.initialiseEventHandler(idTableMain, flagInitialised, (table) => {
|
||||
this.cacheRowBlank();
|
||||
});
|
||||
}
|
||||
}
|
||||
cacheRowBlank() {
|
||||
@@ -211,6 +255,7 @@ export default class TableBasePage extends BasePage {
|
||||
}
|
||||
hookupSlidersDisplayOrderTable() {
|
||||
let selectorDisplayOrder = idTableMain + ' tbody tr td.' + flagDisplayOrder + ' input.' + flagSlider + '.' + flagDisplayOrder;
|
||||
/*
|
||||
Events.initialiseEventHandler(selectorDisplayOrder, flagInitialised, (sliderDisplayOrder) => {
|
||||
/*
|
||||
sliderDisplayOrder.setAttribute('draggable', true);
|
||||
@@ -220,12 +265,53 @@ export default class TableBasePage extends BasePage {
|
||||
sliderDisplayOrder.addEventListener('dragleave', this.handleDragSliderLeave.bind(this), false);
|
||||
sliderDisplayOrder.addEventListener('drop', this.handleDropSlider.bind(this), false);
|
||||
sliderDisplayOrder.addEventListener('dragend', this.handleDragSliderEnd.bind(this), false);
|
||||
*/
|
||||
*
|
||||
sliderDisplayOrder.addEventListener('change', (event) => {
|
||||
console.log("slider change event");
|
||||
this.handleChangeElementCellTable(sliderDisplayOrder);
|
||||
});
|
||||
});
|
||||
*/
|
||||
this.hookupChangeHandlerTableCells(selectorDisplayOrder);
|
||||
}
|
||||
hookupChangeHandlerTableCells(inputSelector, handler = (event, element) => { this.handleChangeElementCellTable(event, element); }) {
|
||||
/*
|
||||
Events.initialiseEventHandler(inputSelector, flagInitialised, (input) => {
|
||||
input.addEventListener("change", (event) => {
|
||||
handler(event, input);
|
||||
});
|
||||
});
|
||||
*/
|
||||
this.hookupEventHandler("change", inputSelector, handler);
|
||||
}
|
||||
handleChangeElementCellTable(event, element) {
|
||||
let row = DOM.getRowFromElement(element);
|
||||
let td = DOM.getCellFromElement(element);
|
||||
console.log("td: ", td);
|
||||
let wasDirtyRow = DOM.hasDirtyChildrenContainer(row);
|
||||
let wasDirtyElement = element.classList.contains(flagDirty);
|
||||
let isDirtyElement = DOM.updateAndCheckIsElementDirty(element);
|
||||
console.log("isDirtyElement: ", isDirtyElement);
|
||||
console.log("wasDirtyElement: ", wasDirtyElement);
|
||||
if (isDirtyElement != wasDirtyElement) {
|
||||
DOM.handleDirtyElement(td, isDirtyElement);
|
||||
let isNowDirtyRow = DOM.hasDirtyChildrenContainer(row);
|
||||
console.log("isNowDirtyRow: ", isNowDirtyRow);
|
||||
console.log("wasDirtyRow: ", wasDirtyRow);
|
||||
if (isNowDirtyRow != wasDirtyRow) {
|
||||
DOM.handleDirtyElement(row, isNowDirtyRow);
|
||||
let rows = this.getTableRecords(true);
|
||||
let existsDirtyRecord = rows.length > 0;
|
||||
console.log("dirty records:", rows);
|
||||
console.log("existsDirtyRecord:", existsDirtyRecord);
|
||||
this.toggleShowButtonsSaveCancel(existsDirtyRecord);
|
||||
}
|
||||
}
|
||||
}
|
||||
hookupChangeHandlerTableCellsWhenNotCollapsed(inputSelector, handler = (event, element) => {
|
||||
if (!element.classList.contains(flagCollapsed)) this.handleChangeElementCellTable(event, element);
|
||||
}) {
|
||||
this.hookupEventHandler("change", inputSelector, handler);
|
||||
}
|
||||
/* ToDo: Fix this slider drag and drop functionality
|
||||
handleDragSliderStart(event) {
|
||||
@@ -286,158 +372,65 @@ export default class TableBasePage extends BasePage {
|
||||
}
|
||||
*/
|
||||
hookupTextareasCodeTable() {
|
||||
let selectorCode = idTableMain + ' tbody tr td.' + flagCode + ' textarea';
|
||||
Events.initialiseEventHandler(selectorCode, flagInitialised, (textareaCode) => {
|
||||
textareaCode.addEventListener("change", (event) => {
|
||||
console.log("textarea change event");
|
||||
this.handleChangeElementCellTable(textareaCode);
|
||||
});
|
||||
});
|
||||
}
|
||||
handleChangeElementCellTable(element) {
|
||||
let row = DOM.getRowFromElement(element);
|
||||
let td = DOM.getCellFromElement(element);
|
||||
console.log("td: ", td);
|
||||
let wasDirtyRow = this.isDirtyRow(row);
|
||||
let wasDirtyElement = element.classList.contains(flagDirty);
|
||||
let isDirtyElement = DOM.isElementDirty(element);
|
||||
console.log("isDirtyElement: ", isDirtyElement);
|
||||
console.log("wasDirtyElement: ", wasDirtyElement);
|
||||
if (isDirtyElement != wasDirtyElement) {
|
||||
DOM.handleDirtyElement(td, isDirtyElement);
|
||||
let isNowDirtyRow = this.isDirtyRow(row);
|
||||
console.log("isNowDirtyRow: ", isNowDirtyRow);
|
||||
console.log("wasDirtyRow: ", wasDirtyRow);
|
||||
if (isNowDirtyRow != wasDirtyRow) {
|
||||
DOM.handleDirtyElement(row, isNowDirtyRow);
|
||||
let rows = this.getTableRecords(true);
|
||||
let existsDirtyRecord = rows.length > 0;
|
||||
console.log("dirty records:", rows);
|
||||
console.log("existsDirtyRecord:", existsDirtyRecord);
|
||||
this.toggleShowButtonsSaveCancel(existsDirtyRecord);
|
||||
}
|
||||
}
|
||||
}
|
||||
isDirtyRow(row) {
|
||||
throw new Error("Subclass of TableBasePage must implement method isDirtyRow().");
|
||||
}
|
||||
toggleShowButtonsSaveCancel(show, buttonSave = null, buttonCancel = null) {
|
||||
if (buttonSave == null) buttonSave = document.querySelector(idFormFilters + ' button.' + flagSave);
|
||||
if (buttonCancel == null) buttonCancel = document.querySelector(idFormFilters + ' button.' + flagCancel);
|
||||
if (show) {
|
||||
buttonCancel.classList.remove(flagCollapsed);
|
||||
buttonSave.classList.remove(flagCollapsed);
|
||||
} else {
|
||||
buttonCancel.classList.add(flagCollapsed);
|
||||
buttonSave.classList.add(flagCollapsed);
|
||||
}
|
||||
}
|
||||
handleChangeSelectCellTable(element) {
|
||||
let row = DOM.getRowFromElement(element);
|
||||
let td = DOM.getCellFromElement(element);
|
||||
console.log("td: ", td);
|
||||
let wasDirtyRow = this.isDirtyRow(row);
|
||||
let wasDirtyElement = element.classList.contains(flagDirty);
|
||||
let isDirtyElement = DOM.isElementDirty(element);
|
||||
console.log("isDirtyElement: ", isDirtyElement);
|
||||
console.log("wasDirtyElement: ", wasDirtyElement);
|
||||
if (isDirtyElement != wasDirtyElement) {
|
||||
DOM.handleDirtyElement(td, isDirtyElement);
|
||||
let optionSelected = element.options[element.selectedIndex];
|
||||
td.setAttribute(attrIdAccessLevel, optionSelected.value);
|
||||
td.setAttribute(flagAccessLevelRequired, optionSelected.textcontent);
|
||||
let isNowDirtyRow = this.isDirtyRow(row);
|
||||
console.log("isNowDirtyRow: ", isNowDirtyRow);
|
||||
console.log("wasDirtyRow: ", wasDirtyRow);
|
||||
if (isNowDirtyRow != wasDirtyRow) {
|
||||
DOM.handleDirtyElement(row, isNowDirtyRow);
|
||||
let rows = this.getTableRecords(true);
|
||||
let existsDirtyRecord = rows.length > 0;
|
||||
console.log("dirty records:", rows);
|
||||
console.log("existsDirtyRecord:", existsDirtyRecord);
|
||||
this.toggleShowButtonsSaveCancel(existsDirtyRecord);
|
||||
}
|
||||
}
|
||||
this.hookupChangeHandlerTableCells(idTableMain + ' tbody tr td.' + flagCode + ' textarea');
|
||||
}
|
||||
hookupTextareasNameTable() {
|
||||
let selectorName = idTableMain + ' tbody tr td.' + flagName + ' textarea';
|
||||
Events.initialiseEventHandler(selectorName, flagInitialised, (textareaName) => {
|
||||
textareaName.addEventListener("change", (event) => {
|
||||
console.log("textarea change event");
|
||||
this.handleChangeElementCellTable(textareaName);
|
||||
});
|
||||
});
|
||||
this.hookupChangeHandlerTableCells(idTableMain + ' tbody tr td.' + flagName + ' textarea');
|
||||
}
|
||||
hookupTextareasDescriptionTable() {
|
||||
let selectorDescription = idTableMain + ' tbody tr td.' + flagDescription + ' textarea';
|
||||
Events.initialiseEventHandler(selectorDescription, flagInitialised, (textareaDescription) => {
|
||||
textareaDescription.addEventListener("change", (event) => {
|
||||
console.log("textarea change event");
|
||||
this.handleChangeElementCellTable(textareaDescription);
|
||||
});
|
||||
});
|
||||
this.hookupChangeHandlerTableCells(idTableMain + ' tbody tr td.' + flagDescription + ' textarea');
|
||||
}
|
||||
hookupInputsActiveTable() {
|
||||
let selectorActive = idTableMain + ' tbody tr td.' + flagActive + ' input[type="checkbox"]';
|
||||
Events.initialiseEventHandler(selectorActive, flagInitialised, (inputActive) => {
|
||||
inputActive.addEventListener("change", (event) => {
|
||||
console.log("input change event");
|
||||
this.handleChangeElementCellTable(inputActive);
|
||||
});
|
||||
});
|
||||
this.hookupChangeHandlerTableCells(idTableMain + ' tbody tr td.' + flagActive + ' input[type="checkbox"]');
|
||||
}
|
||||
hookupTdsAccessLevel() {
|
||||
Events.initialiseEventHandler(idTableMain + ' tbody td.' + flagAccessLevel, flagInitialised, (tdAccessLevel) => {
|
||||
tdAccessLevel.addEventListener("click", (event) => { this.handleClickTdAccessLevel(event); } );
|
||||
let cellSelector = idTableMain + ' tbody td.' + flagAccessLevel;
|
||||
this.hookupTableCellDdlPreviews(cellSelector, Utils.getListFromDict(accessLevels));
|
||||
}
|
||||
hookupTableCellDdlPreviews(cellSelector, optionList, ddlHookup = (event, element) => { this.hookupTableCellDdls(event, element); }) {
|
||||
this.hookupEventHandler("click", cellSelector, (event, td) => {
|
||||
// if (td.querySelector('select')) return;
|
||||
this.handleClickTableCellDdlPreview(event, td, optionList, cellSelector, (event, element) => { ddlHookup(event, element); });
|
||||
});
|
||||
}
|
||||
handleClickTdAccessLevel(event) {
|
||||
console.log("tdAccessLevel clicked");
|
||||
event.stopPropagation();
|
||||
let tdAccessLevel = DOM.getCellFromElement(event.target);
|
||||
console.log("tdAccessLevel: ", tdAccessLevel);
|
||||
let row = DOM.getRowFromElement(tdAccessLevel);
|
||||
let idAccessLevelSelected = tdAccessLevel.querySelector('div.' + flagAccessLevel).getAttribute(attrIdAccessLevel);
|
||||
let ddlAccessLevel = document.createElement('select');
|
||||
ddlAccessLevel.classList.add(flagAccessLevel);
|
||||
ddlAccessLevel.setAttribute(attrValueCurrent, idAccessLevelSelected);
|
||||
ddlAccessLevel.setAttribute(attrValuePrevious, idAccessLevelSelected);
|
||||
optionsAccessLevel.forEach((accessLevel) => {
|
||||
let option = document.createElement('option');
|
||||
option.value = accessLevel.value;
|
||||
option.textContent = accessLevel.text;
|
||||
if (accessLevel.value == idAccessLevelSelected) option.selected = true;
|
||||
ddlAccessLevel.appendChild(option);
|
||||
});
|
||||
let tdAccessLevelNew = tdAccessLevel.cloneNode(true);
|
||||
tdAccessLevelNew.innerHTML = '';
|
||||
tdAccessLevelNew.appendChild(ddlAccessLevel);
|
||||
row.replaceChild(tdAccessLevelNew, tdAccessLevel);
|
||||
this.hookupDdlsAccessLevelTable();
|
||||
hookupTableCellDdls(ddlSelector) {
|
||||
this.hookupEventHandler("change", ddlSelector, (event, element) => { this.handleChangeTableCellDdl(event, element); });
|
||||
}
|
||||
hookupDdlsAccessLevelTable() {
|
||||
Events.initialiseEventHandler(idTableMain + ' tbody select.' + flagAccessLevel, flagInitialised, (ddlAccessLevel) => {
|
||||
ddlAccessLevel.addEventListener("change", (event) => {
|
||||
event.stopPropagation();
|
||||
this.handleChangeDdlAccessLevelTable(ddlAccessLevel);
|
||||
});
|
||||
handleClickTableCellDdlPreview(event, td, optionObjectList, cellSelector, ddlHookup = (event, element) => { this.hookupTableCellDdls(event, element); }) {
|
||||
if (td.querySelector('select')) return;
|
||||
// td.removeEventListener("click", ddlHookup);
|
||||
console.log("click table cell ddl preview");
|
||||
let tdNew = td.cloneNode(true);
|
||||
td.parentNode.replaceChild(tdNew, td);
|
||||
let idSelected = tdNew.getAttribute(attrValueCurrent);
|
||||
tdNew.innerHTML = '';
|
||||
let ddl = document.createElement('select');
|
||||
DOM.setElementValuesCurrentAndPrevious(ddl, DOM.getElementAttributeValueCurrent(tdNew));
|
||||
let optionJson, option;
|
||||
console.log({optionObjectList, cellSelector});
|
||||
optionObjectList.forEach((optionObjectJson) => {
|
||||
optionJson = BusinessObjects.getOptionJsonFromObjectJson(optionObjectJson, idSelected);
|
||||
option = DOM.createOption(optionJson);
|
||||
ddl.appendChild(option);
|
||||
});
|
||||
tdNew.appendChild(ddl);
|
||||
let ddlSelector = cellSelector + ' select';
|
||||
ddlHookup(ddlSelector);
|
||||
}
|
||||
handleChangeDdlAccessLevelTable(ddlAccessLevel) {
|
||||
let row = DOM.getRowFromElement(ddlAccessLevel);
|
||||
let td = DOM.getCellFromElement(ddlAccessLevel);
|
||||
handleChangeTableCellDdl(event, ddl) {
|
||||
let row = DOM.getRowFromElement(ddl);
|
||||
let td = DOM.getCellFromElement(ddl);
|
||||
console.log("td: ", td);
|
||||
let wasDirtyRow = this.isDirtyRow(row);
|
||||
let wasDirtyElement = ddlAccessLevel.classList.contains(flagDirty);
|
||||
let isDirtyElement = DOM.isElementDirty(ddlAccessLevel);
|
||||
let wasDirtyRow = DOM.hasDirtyChildrenContainer(row);
|
||||
let wasDirtyElement = ddl.classList.contains(flagDirty);
|
||||
let isDirtyElement = DOM.updateAndCheckIsElementDirty(ddl);
|
||||
console.log("isDirtyElement: ", isDirtyElement);
|
||||
console.log("wasDirtyElement: ", wasDirtyElement);
|
||||
if (isDirtyElement != wasDirtyElement) {
|
||||
DOM.handleDirtyElement(td, isDirtyElement);
|
||||
let optionSelected = ddlAccessLevel.options[ddlAccessLevel.selectedIndex];
|
||||
td.setAttribute(attrIdAccessLevel, optionSelected.value);
|
||||
td.setAttribute(flagAccessLevelRequired, optionSelected.textcontent);
|
||||
let isNowDirtyRow = this.isDirtyRow(row);
|
||||
let optionSelected = ddl.options[ddl.selectedIndex];
|
||||
DOM.setElementAttributeValueCurrent(td, optionSelected.value);
|
||||
let isNowDirtyRow = DOM.hasDirtyChildrenContainer(row);
|
||||
console.log("isNowDirtyRow: ", isNowDirtyRow);
|
||||
console.log("wasDirtyRow: ", wasDirtyRow);
|
||||
if (isNowDirtyRow != wasDirtyRow) {
|
||||
@@ -450,6 +443,13 @@ export default class TableBasePage extends BasePage {
|
||||
}
|
||||
}
|
||||
}
|
||||
hookupTableCellDDlPreviewsWhenNotCollapsed(cellSelector, optionList, ddlHookup = (event, element) => { this.hookupTableCellDdls(event, element); }) {
|
||||
this.hookupEventHandler("click", cellSelector, (event, td) => {
|
||||
let div = td.querySelector('div');
|
||||
if (!div || div.classList.contains(flagCollapsed)) return;
|
||||
this.handleClickTableCellDdlPreview(event, td, optionList, cellSelector, (event, element) => { ddlHookup(event, element); });
|
||||
});
|
||||
}
|
||||
leave() {
|
||||
if (this.constructor === TableBasePage) {
|
||||
throw new Error("Must implement leave() method.");
|
||||
@@ -459,7 +459,19 @@ export default class TableBasePage extends BasePage {
|
||||
let dataPage = {};
|
||||
dataPage[flagFormFilters] = DOM.convertForm2JSON(formFilters);
|
||||
this.setLocalStoragePage(dataPage);
|
||||
_rowBlank = null;
|
||||
// _rowBlank = null;
|
||||
}
|
||||
|
||||
toggleColumnHasClassnameFlag(columnFlag, isRequiredFlag, classnameFlag) {
|
||||
let table = this.getTableMain();
|
||||
let columnTh = table.querySelector('th.' + columnFlag);
|
||||
let columnThHasFlag = columnTh.classList.contains(classnameFlag);
|
||||
if (isRequiredFlag == columnThHasFlag) return;
|
||||
let columnTds = table.querySelectorAll('td.' + columnFlag);
|
||||
DOM.toggleElementHasClassnameFlag(columnTh, isRequiredFlag, classnameFlag);
|
||||
columnTds.forEach((columnTd) => {
|
||||
DOM.toggleElementHasClassnameFlag(columnTd, isRequiredFlag, classnameFlag);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -478,6 +490,7 @@ export class PageStoreProductCategories extends TableBasePage {
|
||||
hookupFilters() {}
|
||||
loadRowTable(rowJson) {}
|
||||
getJsonRow(row) {}
|
||||
initialiseRowNew(row) {}
|
||||
hookupTableMain() {}
|
||||
isDirtyRow(row) {}
|
||||
leave() {}
|
||||
|
||||
@@ -15,24 +15,24 @@ export default class PageAdminHome extends BasePage {
|
||||
}
|
||||
|
||||
hookupAdminStore() {
|
||||
this.hookupButtonNavStoreProductCategories();
|
||||
this.hookupButtonNavStoreProducts();
|
||||
this.hookupButtonNavStoreProductPermutations();
|
||||
this.hookupButtonNavStoreProductPrices();
|
||||
this.hookupButtonNavStoreStockItems();
|
||||
this.hookupButtonNavStoreProductVariations();
|
||||
this.hookupButtonsNavStoreProductCategories();
|
||||
this.hookupButtonsNavStoreProducts();
|
||||
this.hookupButtonsNavStoreProductPermutations();
|
||||
this.hookupButtonsNavStoreProductPrices();
|
||||
this.hookupButtonsNavStoreStockItems();
|
||||
this.hookupButtonsNavStoreProductVariations();
|
||||
|
||||
this.hookupButtonNavAdminStoreStripeProducts();
|
||||
this.hookupButtonNavAdminStoreStripePrices();
|
||||
this.hookupButtonsNavAdminStoreStripeProducts();
|
||||
this.hookupButtonsNavAdminStoreStripePrices();
|
||||
}
|
||||
hookupButtonNavAdminStoreStripeProducts() {
|
||||
hookupButtonsNavAdminStoreStripeProducts() {
|
||||
Events.initialiseEventHandler('.' + flagNavAdminStoreStripeProducts, flagInitialised, function(navigator) {
|
||||
navigator.addEventListener("click", function(event) {
|
||||
this.router.navigateToHash(hashPageAdminStoreStripeProducts);
|
||||
});
|
||||
});
|
||||
}
|
||||
hookupButtonNavAdminStoreStripePrices() {
|
||||
hookupButtonsNavAdminStoreStripePrices() {
|
||||
Events.initialiseEventHandler('.' + flagNavAdminStoreStripePrices, flagInitialised, function(navigator) {
|
||||
navigator.addEventListener("click", function(event) {
|
||||
this.router.navigateToHash(hashPageAdminStoreStripePrices);
|
||||
|
||||
@@ -10,7 +10,7 @@ export default class PageHome extends BasePage {
|
||||
|
||||
initialize() {
|
||||
this.sharedInitialize();
|
||||
this.hookupButtonNavContact();
|
||||
this.hookupButtonsNavContact();
|
||||
}
|
||||
|
||||
leave() {
|
||||
|
||||
@@ -124,12 +124,12 @@ export default class PageStoreBasket extends BasePage {
|
||||
let keys = [keyNameFull, keyPhoneNumber, keyPostcode, keyAddress1, keyAddress2, keyCity, keyCounty];
|
||||
console.log('ajaxData:');
|
||||
console.log(ajaxData);
|
||||
ajaxData[keyForm][keyInfoIdentical] = getElementCurrentValue(elForm.querySelector('#' + keyInfoIdentical));
|
||||
ajaxData[keyForm][keyInfoIdentical] = getElementValueCurrent(elForm.querySelector('#' + keyInfoIdentical));
|
||||
for (var k in keys) {
|
||||
if (idOverlayInfo == idOverlayInfoBilling && ajaxData[keyForm][keyInfoIdentical]) {
|
||||
ajaxData[keyForm][keys[k]] = getElementCurrentValue(elFormDelivery.querySelector('#' + keys[k]));
|
||||
ajaxData[keyForm][keys[k]] = getElementValueCurrent(elFormDelivery.querySelector('#' + keys[k]));
|
||||
} else {
|
||||
ajaxData[keyForm][keys[k]] = getElementCurrentValue(elForm.querySelector('#' + keys[k]));
|
||||
ajaxData[keyForm][keys[k]] = getElementValueCurrent(elForm.querySelector('#' + keys[k]));
|
||||
}
|
||||
}
|
||||
console.log('ajaxData:');
|
||||
@@ -181,7 +181,7 @@ export default class PageStoreBasket extends BasePage {
|
||||
let elFormDelivery = document.querySelectorAll(idOverlayInfoDelivery).querySelector('form');
|
||||
|
||||
for (var k in keys) {
|
||||
elFormBilling.querySelector('#' + keys[k]).value = getElementCurrentValue(elFormDelivery.querySelector('#' + keys[k]));
|
||||
elFormBilling.querySelector('#' + keys[k]).value = getElementValueCurrent(elFormDelivery.querySelector('#' + keys[k]));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -7,20 +7,21 @@ import DOM from "../../dom.js";
|
||||
import { isEmpty } from "../../lib/utils.js";
|
||||
|
||||
export default class StoreMixinPage {
|
||||
constructor() {
|
||||
constructor(pageCurrent) {
|
||||
this.page = pageCurrent;
|
||||
}
|
||||
|
||||
initialize(thisPage) {
|
||||
console.log('hookup store start for ', DOM.getHashPageCurrent());
|
||||
this.hookupFiltersStore();
|
||||
initialize() {
|
||||
console.log('hookup store start for ', this.page.hash);
|
||||
this.hookupFilters();
|
||||
this.hookupLocalStorageStore();
|
||||
this.hookupBasket();
|
||||
this.hookupButtonsAdd2Basket();
|
||||
this.hookupButtonsAddToBasket();
|
||||
}
|
||||
hookupFiltersStore() {
|
||||
hookupFilterCurrency();
|
||||
hookupFilterDeliveryRegion();
|
||||
hookupFilterIsIncludedVAT();
|
||||
hookupFilters() {
|
||||
this.hookupFilterCurrency();
|
||||
this.hookupFilterDeliveryRegion();
|
||||
this.hookupFilterIsIncludedVAT();
|
||||
}
|
||||
hookupFilterCurrency() {
|
||||
/*
|
||||
@@ -35,7 +36,7 @@ export default class StoreMixinPage {
|
||||
ajaxJSONData('select currency', mapHashToController(hashStoreSelectCurrency), ajaxData, function() { window.location.reload() }, false);
|
||||
|
||||
let optionSelected = elSelector.options[elSelector.selectedIndex]
|
||||
let textSelected = optionSelected.attr(attrDataShort)
|
||||
let textSelected = optionSelected.getAttribute(attrDataShort)
|
||||
|
||||
});
|
||||
});
|
||||
@@ -49,8 +50,8 @@ export default class StoreMixinPage {
|
||||
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.setAttribute(attrTextExpanded, textOption);
|
||||
option.setAttribute(attrTextCollapsed, textOption.substring(0, indexHyphen - 1));
|
||||
option.classList.add(flagCollapsed);
|
||||
}
|
||||
handleSelectCollapse(dropdownCurrency);
|
||||
@@ -98,8 +99,8 @@ export default class StoreMixinPage {
|
||||
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.setAttribute(attrTextExpanded, textOption);
|
||||
option.setAttribute(attrTextCollapsed, textOption.substring(0, indexHyphen - 1));
|
||||
option.classList.add(flagCollapsed);
|
||||
}
|
||||
|
||||
@@ -143,48 +144,69 @@ export default class StoreMixinPage {
|
||||
console.log("form is included VAT initialised")
|
||||
});
|
||||
}
|
||||
hookupLocalStorageStore() {
|
||||
hookupLocalStorage() {
|
||||
|
||||
// setupPageLocalStorage(hashPageCurrent);
|
||||
// let lsPage = getPageLocalStorage(hashPageCurrent);
|
||||
// let d = {}
|
||||
// d[keyBasket] = LocalStorage.getLocalStorage(keyBasket); // (keyBasket in lsPage) ? lsPage[keyBasket] : {'items': []};
|
||||
// console.log('d:'); console.log(d);
|
||||
let basket;
|
||||
let createNewBasket = true;
|
||||
if (true) { // !isUserLoggedIn) {
|
||||
try {
|
||||
basket = LocalStorage.getLocalStorage(keyBasket);
|
||||
console.log('basket found: '); console.log(basket);
|
||||
createNewBasket = Validation.isEmpty(basket);
|
||||
}
|
||||
catch {
|
||||
|
||||
}
|
||||
// lsPage[keyBasket] = ajaxJSONData(keyBasket, hashStoreBasketLoad, d, loadBasket, false);
|
||||
let basketLocalStorage = LocalStorage.getLocalStorage(keyBasket);
|
||||
if (!StoreMixinPage.validateBasket(basketLocalStorage)) {
|
||||
console.log('locally-stored basket not valid');
|
||||
basketLocalStorage = StoreMixinPage.makeNewBasket();
|
||||
}
|
||||
else {
|
||||
// store basket from server in localStorage
|
||||
|
||||
}
|
||||
if (createNewBasket) {
|
||||
basket = {};
|
||||
basket[keyItems] = [];
|
||||
basket[keyIsIncludedVAT] = true;
|
||||
basket[keyIdCurrency] = 1;
|
||||
basket[keyIdRegionDelivery] = 1;
|
||||
let basketServer = StoreMixinPage.validateBasket(userBasket) ? userBasket : basketLocalStorage;
|
||||
let basket = StoreMixinPage.areEqualBaskets(basketLocalStorage, basketServer) ? basketServer : StoreMixinPage.mergeBaskets(basketLocalStorage, basketServer);
|
||||
if (!StoreMixinPage.areEqualBaskets(basketLocalStorage, basket)) {
|
||||
LocalStorage.setLocalStorage(keyBasket, basket);
|
||||
console.log("new local basket created");
|
||||
}
|
||||
let ajaxData = {}
|
||||
ajaxData[keyBasket] = basket;
|
||||
// console.log("hookupLocalStorageStore\nhashStoreBasketLoad: " + hashStoreBasketLoad + "\n");
|
||||
// ajaxData[keyIsIncludedVAT] = LocalStorage.getLocalStorage(keyIsIncludedVAT);
|
||||
console.log('ajax:' + ajaxData);
|
||||
ajaxJSONData(keyBasket, mapHashToController(hashStoreBasketLoad), ajaxData, loadBasket, false);
|
||||
if (!StoreMixinPage.areEqualBaskets(basketServer, basket)) {
|
||||
/*
|
||||
let ajaxData = {}
|
||||
ajaxData[keyBasket] = basket;
|
||||
// console.log("hookupLocalStorageStore\nhashStoreBasketLoad: " + hashStoreBasketLoad + "\n");
|
||||
// ajaxData[keyIsIncludedVAT] = LocalStorage.getLocalStorage(keyIsIncludedVAT);
|
||||
console.log('ajax:' + ajaxData);
|
||||
ajaxJSONData(keyBasket, mapHashToController(hashStoreBasketLoad), ajaxData, loadBasket, false);
|
||||
*/
|
||||
API.saveStoreBasket(basket);
|
||||
}
|
||||
userBasket = basket;
|
||||
}
|
||||
static validateBasket(basket) {
|
||||
return (
|
||||
Validation.isEmpty(basket) &&
|
||||
Validation.dictHasKey(basket, keyItems) &&
|
||||
Validation.dictHasKey(basket, keyIsIncludedVAT) &&
|
||||
Validation.dictHasKey(basket, keyIdCurrency) &&
|
||||
Validation.dictHasKey(basket, keyIdRegionDelivery)
|
||||
);
|
||||
}
|
||||
static makeNewBasket() {
|
||||
return {
|
||||
[keyItems]: [],
|
||||
[keyIsIncludedVAT]: true,
|
||||
[keyIdCurrency]: 1,
|
||||
[keyIdRegionDelivery]: 1
|
||||
};
|
||||
}
|
||||
static areEqualBaskets(basket1, basket2) {
|
||||
return JSON.stringify(basket1) === JSON.stringify(basket2);
|
||||
}
|
||||
static mergeBaskets(basketPrimary, basketSecondary) {
|
||||
let basket = {...basketSecondary, ...basketPrimary};
|
||||
let items = {};
|
||||
for (let item of basketSecondary[keyItems]) {
|
||||
items[item[keyIdPermutation]] = item.Quantity;
|
||||
}
|
||||
for (let item of basketPrimary[keyItems]) {
|
||||
items[item[keyIdPermutation]] = items[item[keyIdPermutation]] ? items[item[keyIdPermutation]] + item.Quantity : item.Quantity;
|
||||
}
|
||||
basket[keyItems] = Object.values(items);
|
||||
return basket;
|
||||
}
|
||||
hookupBasket() {
|
||||
|
||||
// const containerBasket = document.querySelectorAll(idContainerBasket);
|
||||
this.toggleShowButtonCheckout(); // containerBasket
|
||||
this.hookupButtonCheckout();
|
||||
@@ -193,34 +215,24 @@ export default class StoreMixinPage {
|
||||
this.hookupBasketEditInputs();
|
||||
this.hookupDeleteBasketItemButtons();
|
||||
}
|
||||
toggleShowButtonCheckout() { // containerBasket
|
||||
|
||||
toggleShowButtonCheckout() {
|
||||
console.log("toggling checkout button");
|
||||
|
||||
const btnCheckout = document.querySelectorAll(idButtonCheckout);
|
||||
const buttonCheckout = document.querySelectorAll(idButtonCheckout);
|
||||
const labelBasketEmpty = document.querySelectorAll(idLabelBasketEmpty);
|
||||
|
||||
// let lsPage = getPageLocalStorage(hashPageCurrent);
|
||||
// let basket = lsPage[keyBasket]['items'];
|
||||
// let products = containerBasket.filter('');
|
||||
let basket = LocalStorage.getLocalStorage(keyBasket);
|
||||
|
||||
if (basket['items'].length == 0) {
|
||||
btnCheckout.style.display = "none";
|
||||
if (userBasket['items'].length == 0) {
|
||||
buttonCheckout.style.display = "none";
|
||||
labelBasketEmpty.style.display = "";
|
||||
} else {
|
||||
btnCheckout.style.display = "";
|
||||
buttonCheckout.style.display = "";
|
||||
labelBasketEmpty.style.display = "none";
|
||||
}
|
||||
}
|
||||
hookupButtonCheckout() {
|
||||
|
||||
console.log("hooking up checkout button");
|
||||
|
||||
const btnCheckout = document.querySelectorAll(idButtonCheckout);
|
||||
const buttonCheckout = document.querySelectorAll(idButtonCheckout);
|
||||
// let lsPage = getPageLocalStorage(hashPageCurrent);
|
||||
Events.initialiseEventHandler(btnCheckout, flagInitialised, function() {
|
||||
btnCheckout.addEventListener("click", function() {
|
||||
Events.initialiseEventHandler(buttonCheckout, flagInitialised, function() {
|
||||
buttonCheckout.addEventListener("click", function() {
|
||||
/*
|
||||
//setupPageLocalStorageNext(hashPageStoreBasket);
|
||||
let basket = LocalStorage.getLocalStorage(keyBasket);
|
||||
@@ -230,23 +242,24 @@ export default class StoreMixinPage {
|
||||
|
||||
ajaxJSONData('checkout', mapHashToController(hashPageStoreBasket), ajaxData, null, false);
|
||||
*/
|
||||
goToPage(hashPageStoreBasket);
|
||||
this.router.navigateToHash(hashPageStoreBasket);
|
||||
});
|
||||
});
|
||||
}
|
||||
hookupBasketItemPlusAndMinusButtons() {
|
||||
const minVal = 1;
|
||||
const basket = document.querySelector(idFormBasket);
|
||||
// Basket Add
|
||||
// Increment
|
||||
document.querySelectorAll('div.btn-increment[' + attrFormType + '=' + typeFormBasketAdd + ']').each(function() {
|
||||
basket.querySelectorAll('div.btn-increment[' + attrFormType + '=' + typeFormBasketAdd + ']').each(function() {
|
||||
let elButton = this;
|
||||
Events.initialiseEventHandler(elButton, flagInitialised, function(){
|
||||
elButton.addEventListener("click", function(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
let elInput = document.querySelectorAll(getFormProductSelector(typeFormBasketAdd, elButton)).querySelector('input[type="number"]');
|
||||
// console.log('input selector ='); console.log('form[' + attrFormType + '=' + elButton.attr(attrFormType) + '][' + attrIdProduct + '=' + elButton.attr(attrIdProduct) + ']');
|
||||
let newVal = parseInt(getElementCurrentValue(elInput));
|
||||
// console.log('input selector ='); console.log('form[' + attrFormType + '=' + elButton.getAttribute(attrFormType) + '][' + attrIdProduct + '=' + elButton.getAttribute(attrIdProduct) + ']');
|
||||
let newVal = parseInt(DOM.getElementValueCurrent(elInput));
|
||||
if (isNaN(newVal)) newVal = minVal;
|
||||
newVal += 1;
|
||||
elInput.val(newVal);
|
||||
@@ -254,15 +267,15 @@ export default class StoreMixinPage {
|
||||
});
|
||||
});
|
||||
// Decrement
|
||||
document.querySelectorAll('div.btn-decrement[' + attrFormType + '=' + typeFormBasketAdd + ']').each(function() {
|
||||
basket.querySelectorAll('div.btn-decrement[' + attrFormType + '=' + typeFormBasketAdd + ']').each(function() {
|
||||
let elButton = this;
|
||||
Events.initialiseEventHandler(elButton, flagInitialised, function(){
|
||||
elButton.addEventListener("click", function(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
// let product = document.querySelectorAll('.card.subcard[' + attrIdProduct +'=' + elButton.attr(attrIdProduct) + ']');
|
||||
// let product = document.querySelectorAll('.card.subcard[' + attrIdProduct +'=' + elButton.getAttribute(attrIdProduct) + ']');
|
||||
let elInput= document.querySelectorAll(getFormProductSelector(typeFormBasketAdd, elButton)).querySelector('input[type="number"]');
|
||||
let newVal = parseInt(getElementCurrentValue(elInput));
|
||||
let newVal = parseInt(DOM.getElementValueCurrent(elInput));
|
||||
if (isNaN(newVal)) newVal = minVal;
|
||||
newVal = Math.max(minVal, newVal - 1);
|
||||
elInput.val(newVal);
|
||||
@@ -272,15 +285,15 @@ export default class StoreMixinPage {
|
||||
|
||||
// Basket Edit
|
||||
// Increment
|
||||
document.querySelectorAll('div.btn-increment[' + attrFormType + '=' + typeFormBasketEdit + ']').each(function() {
|
||||
basket.querySelectorAll('div.btn-increment[' + attrFormType + '=' + typeFormBasketEdit + ']').each(function() {
|
||||
let elButton = this;
|
||||
Events.initialiseEventHandler(elButton, flagInitialised, function(){
|
||||
elButton.addEventListener("click", function(event) {
|
||||
event.stopPropagation();
|
||||
// basketItem = document.querySelectorAll('.card.subcard[' + attrIdProduct +'=' + elButton.attr(attrIdProduct) + ']');
|
||||
// basketItem = document.querySelectorAll('.card.subcard[' + attrIdProduct +'=' + elButton.getAttribute(attrIdProduct) + ']');
|
||||
let elInput = document.querySelectorAll(getFormProductSelector(typeFormBasketEdit, elButton)).querySelector('input[type="number"]');
|
||||
// console.log('input selector ='); console.log('form[' + attrFormType + '=' + elButton.attr(attrFormType) + '][' + attrIdProduct + '=' + elButton.attr(attrIdProduct) + ']');
|
||||
let newVal = parseInt(getElementCurrentValue(elInput));
|
||||
// console.log('input selector ='); console.log('form[' + attrFormType + '=' + elButton.getAttribute(attrFormType) + '][' + attrIdProduct + '=' + elButton.getAttribute(attrIdProduct) + ']');
|
||||
let newVal = parseInt(DOM.getElementValueCurrent(elInput));
|
||||
if (isNaN(newVal)) newVal = minVal;
|
||||
newVal += 1;
|
||||
elInput.val(newVal);
|
||||
@@ -289,13 +302,13 @@ export default class StoreMixinPage {
|
||||
});
|
||||
});
|
||||
// Decrement
|
||||
document.querySelectorAll('div.btn-decrement[' + attrFormType + '=' + typeFormBasketEdit + ']').each(function() {
|
||||
basket.querySelectorAll('div.btn-decrement[' + attrFormType + '=' + typeFormBasketEdit + ']').each(function() {
|
||||
let elButton = this;
|
||||
Events.initialiseEventHandler(elButton, flagInitialised, function(){
|
||||
elButton.addEventListener("click", function(event) {
|
||||
event.stopPropagation();
|
||||
let elInput= document.querySelectorAll(getFormProductSelector(typeFormBasketEdit, elButton)).querySelector('input[type="number"]');
|
||||
let newVal = parseInt(getElementCurrentValue(elInput));
|
||||
let newVal = parseInt(DOM.getElementValueCurrent(elInput));
|
||||
if (isNaN(newVal)) newVal = minVal;
|
||||
newVal = Math.max(minVal, newVal - 1);
|
||||
elInput.val(newVal);
|
||||
@@ -304,158 +317,69 @@ export default class StoreMixinPage {
|
||||
});
|
||||
});
|
||||
}
|
||||
hookupBasketAddInputs() {
|
||||
|
||||
document.querySelectorAll('form[' + attrFormType + '=' + typeFormBasketAdd + ']').each(function() {
|
||||
let elForm = this;
|
||||
let elInput = elForm.querySelector('input[type="number"]');
|
||||
Events.initialiseEventHandler(elInput, flagInitialised, function(){
|
||||
elInput.addEventListener("change", function(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
});
|
||||
elInput.addEventListener("click", function(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
});
|
||||
hookupBasketAddForms() {
|
||||
let basketAddFormSelector = 'form[' + attrFormType + '=' + typeFormBasketAdd + ']';
|
||||
Events.initialiseEventHandler(basketAddFormSelector, flagInitialised, (basketAddForm) => {
|
||||
let quantityInput = basketAddForm.querySelector('input[type="number"]');
|
||||
quantityInput.addEventListener("change", function(event) {
|
||||
let newVal = parseInt(quantityInput.value);
|
||||
if (isNaN(newVal) || newVal < 0) {
|
||||
quantityInput.value = 0;
|
||||
}
|
||||
});
|
||||
let buttonSubmit = basketAddForm.querySelector('button'); // [type="submit"]
|
||||
buttonSubmit.addEventListener("click", (event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
let newBasketItem = {};
|
||||
newBasketItem[keyIdProductPermutation] = basketAddForm.getAttribute(attrIdPermutation);
|
||||
newBasketItem[keyQuantity] = quantityInput.value;
|
||||
API.storeAddToBasket(newBasketItem);
|
||||
});
|
||||
});
|
||||
}
|
||||
hookupBasketEditInputs() {
|
||||
|
||||
// let elButton, 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"]');
|
||||
Events.initialiseEventHandler(elInput, flagInitialised, function(){
|
||||
elInput.addEventListener("change", function(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
// let lsPage = getPageLocalStorageCurrent();
|
||||
d = {};
|
||||
d[keyBasket]= LocalStorage.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);
|
||||
});
|
||||
hookupBasketEditForms() {
|
||||
let basketEditFormSelector = 'form[' + attrFormType + '=' + typeFormBasketEdit + ']';
|
||||
Events.initialiseEventHandler(basketEditFormSelector, flagInitialised, (basketEditForm) => {
|
||||
let quantityInput = basketEditForm.querySelector('input[type="number"]');
|
||||
quantityInput.addEventListener("change", function(event) {
|
||||
let newVal = parseInt(quantityInput.value);
|
||||
if (isNaN(newVal) || newVal < 0) {
|
||||
quantityInput.value = 0;
|
||||
}
|
||||
if (quantityInput.value != basketEditForm.getAttribute(attrQuantity)) {
|
||||
let newBasketItem = {};
|
||||
newBasketItem[keyIdProductPermutation] = basketEditForm.getAttribute(attrIdPermutation);
|
||||
newBasketItem[keyQuantity] = quantityInput.value;
|
||||
API.storeSaveBasket(newBasketItem);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
hookupDeleteBasketItemButtons() {
|
||||
|
||||
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);
|
||||
Events.initialiseEventHandler(elDelete, flagInitialised, function(){
|
||||
elDelete.addEventListener("click", function(event) {
|
||||
event.stopPropagation();
|
||||
ajaxData = {};
|
||||
ajaxData[keyBasket]= LocalStorage.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);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
getBasket() {
|
||||
|
||||
lsShared = getPageLocalStorage(keyShared);
|
||||
|
||||
return lsShared[keyBasket];
|
||||
}
|
||||
*/
|
||||
|
||||
hookupButtonsAdd2Basket() {
|
||||
|
||||
// let product, btn, lsPage;
|
||||
// [' + attrIdProduct + '=' + elButton.attr(attrIdProduct) + ']
|
||||
document.querySelectorAll('form[' + attrFormType + '="' + typeFormBasketAdd +'"]').each(function() {
|
||||
|
||||
var form = this;
|
||||
|
||||
Events.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 = LocalStorage.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));
|
||||
let deleteButton = basketEditForm.querySelector('button'); // [type="button"]
|
||||
deleteButton.addEventListener("click", (event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
API.storeDeleteBasketItem(basketEditForm.getAttribute(attrIdPermutation));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
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);
|
||||
LocalStorage.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'];
|
||||
|
||||
userBasket = response.data[keyBasket];
|
||||
let basketForm = document.querySelectorAll(idFormBasket);
|
||||
/*
|
||||
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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
basketForm.replaceChildren();
|
||||
let items = userBasket[keyItems];
|
||||
let basketItem;
|
||||
items.forEach(item => {
|
||||
basketItem = document.createElement('div');
|
||||
basketForm.appendChild(basketItem);
|
||||
});
|
||||
*/
|
||||
let htmlBlock = response.data[keyHtmlBlock];
|
||||
basketForm.innerHTML = htmlBlock;
|
||||
this.hookupBasket();
|
||||
}
|
||||
|
||||
hookupBasket();
|
||||
}
|
||||
|
||||
getFormProductSelector(typeForm, elementInForm) {
|
||||
idPermutation = elementInForm.attr(attrIdPermutation);
|
||||
console.log('idPermutation: ', idPermutation);
|
||||
hasPermutation = !Validation.isEmpty(idPermutation);
|
||||
console.log('has permutation: ', hasPermutation);
|
||||
selectorIdPermutation = hasPermutation ? '[' + attrIdPermutation + '=' + idPermutation + ']' : '';
|
||||
return 'form[' + attrFormType + '="' + typeForm + '"][' + attrIdProduct + '=' + elementInForm.attr(attrIdProduct) + ']' + selectorIdPermutation;
|
||||
}
|
||||
|
||||
|
||||
|
||||
getCurrencySelected() {
|
||||
let elementSelectorCurrency = document.querySelectorAll(idSelectorCurrency);
|
||||
let selectedCurrency = elementSelectorCurrency.val();
|
||||
@@ -463,13 +387,6 @@ export default class StoreMixinPage {
|
||||
return selectedCurrency;
|
||||
}
|
||||
|
||||
addMetadataBasketToJSON(jsonData) {
|
||||
jsonData[keyIdCurrency] = LocalStorage.getLocalStorage(keyIdCurrency);
|
||||
jsonData[keyIdRegionDelivery] = LocalStorage.getLocalStorage(keyIdRegionDelivery);
|
||||
jsonData[keyIsIncludedVAT] = LocalStorage.getLocalStorage(keyIsIncludedVAT);
|
||||
return jsonData;
|
||||
}
|
||||
|
||||
hookupStoreCardsProduct() {
|
||||
|
||||
let d; // , lsShared;
|
||||
@@ -477,31 +394,41 @@ export default class StoreMixinPage {
|
||||
Events.initialiseEventHandler(selectorCardProduct, flagInitialised, function(cardProduct) {
|
||||
console.log("initialising product card: ", cardProduct);
|
||||
cardProduct.addEventListener("click", function(event) {
|
||||
// d = { keyIdProduct: product.attr(attrIdProduct) }
|
||||
// d = { keyIdProduct: product.getAttribute(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));
|
||||
console.log("product click: " + cardProduct.getAttribute(attrIdProduct));
|
||||
console.log("permutation click: " + cardProduct.getAttribute(attrIdPermutation));
|
||||
var d = {}
|
||||
d[keyIdProduct] = cardProduct.attr(attrIdProduct)
|
||||
d[keyIdPermutation] = cardProduct.attr(attrIdPermutation)
|
||||
d[keyIdProduct] = cardProduct.getAttribute(attrIdProduct)
|
||||
d[keyIdPermutation] = cardProduct.getAttribute(attrIdPermutation)
|
||||
// send quantity requested
|
||||
goToPage(hashPageStoreProduct, d);
|
||||
}
|
||||
});
|
||||
console.log("click method added for product ID: " + cardProduct.attr(attrIdProduct) + ', permutation ID: ', cardProduct.attr(attrIdPermutation));
|
||||
console.log("click method added for product ID: " + cardProduct.getAttribute(attrIdProduct) + ', permutation ID: ', cardProduct.getAttribute(attrIdPermutation));
|
||||
});
|
||||
}
|
||||
|
||||
leave() {
|
||||
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);
|
||||
leave() {}
|
||||
|
||||
/*
|
||||
getFormProductSelector(typeForm, elementInForm) {
|
||||
idPermutation = elementInForm.getAttribute(attrIdPermutation);
|
||||
console.log('idPermutation: ', idPermutation);
|
||||
hasPermutation = !Validation.isEmpty(idPermutation);
|
||||
console.log('has permutation: ', hasPermutation);
|
||||
selectorIdPermutation = hasPermutation ? '[' + attrIdPermutation + '=' + idPermutation + ']' : '';
|
||||
return 'form[' + attrFormType + '="' + typeForm + '"][' + attrIdProduct + '=' + elementInForm.getAttribute(attrIdProduct) + ']' + selectorIdPermutation;
|
||||
}
|
||||
|
||||
addMetadataBasketToJSON(jsonData) {
|
||||
jsonData[keyIdCurrency] = LocalStorage.getLocalStorage(keyIdCurrency);
|
||||
jsonData[keyIdRegionDelivery] = LocalStorage.getLocalStorage(keyIdRegionDelivery);
|
||||
jsonData[keyIsIncludedVAT] = LocalStorage.getLocalStorage(keyIsIncludedVAT);
|
||||
return jsonData;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
loadFiltersFromLocalStorage(pageHash, parameters_dict) {
|
||||
@@ -517,4 +444,4 @@ export default class StoreMixinPage {
|
||||
goToPage(pageHash, parameters_dict);
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
25
static/js/pages/store/mixin_table.js
Normal file
25
static/js/pages/store/mixin_table.js
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
import Events from "../../lib/events.js";
|
||||
import LocalStorage from "../../lib/local_storage.js";
|
||||
import Validation from "../../lib/validation.js";
|
||||
// import BasePage from "../base.js";
|
||||
import DOM from "../../dom.js";
|
||||
import { isEmpty } from "../../lib/utils.js";
|
||||
import StoreMixinPage from "./mixin.js";
|
||||
|
||||
export default class StoreTableMixinPage extends StoreMixinPage {
|
||||
constructor(pageCurrent) {
|
||||
super(pageCurrent);
|
||||
}
|
||||
initialize() {
|
||||
super.initialize();
|
||||
this.hookupFilters();
|
||||
this.hookupTable();
|
||||
}
|
||||
hookupFilters() {
|
||||
// Implement filter-specific functionality here
|
||||
}
|
||||
hookupTable() {
|
||||
// Implement table-specific functionality here
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
|
||||
|
||||
import Events from "../../lib/events.js";
|
||||
import TableBasePage from "../base_table.js";
|
||||
import API from "../../api.js";
|
||||
import DOM from "../../dom.js";
|
||||
import StoreTableMixinPage from "./mixin_table.js";
|
||||
|
||||
export default class PageStoreProductCategories extends TableBasePage {
|
||||
static hash = hashPageStoreProductCategories;
|
||||
@@ -11,22 +12,21 @@ export default class PageStoreProductCategories extends TableBasePage {
|
||||
|
||||
constructor(router) {
|
||||
super(router);
|
||||
this.storeMixin = new StoreTableMixinPage(this);
|
||||
}
|
||||
|
||||
initialize() {
|
||||
super.initialize();
|
||||
this.sharedInitialize();
|
||||
}
|
||||
|
||||
hookupFilters() {
|
||||
super.hookupFilters();
|
||||
this.sharedHookupFilters();
|
||||
this.hookupFilterIsNotEmpty();
|
||||
this.hookupFilterActive();
|
||||
}
|
||||
hookupFilterIsNotEmpty() {
|
||||
Events.initialiseEventHandler('.' + flagIsNotEmpty, flagInitialised, (filter) => {
|
||||
filter.addEventListener("change", (event) => {
|
||||
PageStoreProductCategories.isDirtyFilter(filter);
|
||||
});
|
||||
this.hookupEventHandler("change", idFormFilters + ' .' + flagIsNotEmpty, (event, filter) => {
|
||||
PageStoreProductCategories.isDirtyFilter(filter);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -47,22 +47,16 @@ export default class PageStoreProductCategories extends TableBasePage {
|
||||
let divAccessLevel = tdAccessLevel.querySelector('div.' + flagAccessLevel);
|
||||
let inputActive = row.querySelector('td.' + flagActive + ' input[type="checkbox"]');
|
||||
|
||||
sliderDisplayOrder.setAttribute(attrValueCurrent, rowJson[flagDisplayOrder]);
|
||||
DOM.setElementValuePrevious(sliderDisplayOrder, rowJson[flagDisplayOrder]);
|
||||
DOM.setElementValueCurrent(textareaCode, rowJson[flagCode]);
|
||||
DOM.setElementValuePrevious(textareaCode, rowJson[flagCode]);
|
||||
DOM.setElementValueCurrent(textareaName, rowJson[flagName]);
|
||||
DOM.setElementValuePrevious(textareaName, rowJson[flagName]);
|
||||
DOM.setElementValueCurrent(textareaDescription, rowJson[flagDescription]);
|
||||
DOM.setElementValuePrevious(textareaDescription, rowJson[flagDescription]);
|
||||
DOM.setElementValuesCurrentAndPrevious(sliderDisplayOrder, rowJson[flagDisplayOrder]);
|
||||
DOM.setElementValuesCurrentAndPrevious(textareaCode, rowJson[flagCode]);
|
||||
DOM.setElementValuesCurrentAndPrevious(textareaName, rowJson[flagName]);
|
||||
DOM.setElementValuesCurrentAndPrevious(textareaDescription, rowJson[flagDescription]);
|
||||
tdAccessLevel.setAttribute(attrIdAccessLevel, rowJson[attrIdAccessLevel]);
|
||||
tdAccessLevel.setAttribute(flagAccessLevelRequired, rowJson[flagAccessLevelRequired]);
|
||||
divAccessLevel.setAttribute(attrIdAccessLevel, rowJson[attrIdAccessLevel]);
|
||||
DOM.setElementValueCurrent(divAccessLevel, rowJson[attrIdAccessLevel]);
|
||||
DOM.setElementValuePrevious(divAccessLevel, rowJson[attrIdAccessLevel]);
|
||||
DOM.setElementValuesCurrentAndPrevious(divAccessLevel, rowJson[attrIdAccessLevel]);
|
||||
divAccessLevel.textContent = rowJson[flagAccessLevelRequired];
|
||||
DOM.setElementValueCurrent(inputActive, rowJson[flagActive]);
|
||||
DOM.setElementValuePrevious(inputActive, rowJson[flagActive]);
|
||||
DOM.setElementValuesCurrentAndPrevious(inputActive, rowJson[flagActive]);
|
||||
row.setAttribute(rowJson[flagKeyPrimary], rowJson[rowJson[flagKeyPrimary]]);
|
||||
|
||||
let table = this.getTableMain();
|
||||
@@ -79,16 +73,26 @@ export default class PageStoreProductCategories extends TableBasePage {
|
||||
let inputActive = row.querySelector('td.' + flagActive + ' input[type="checkbox"]');
|
||||
|
||||
let jsonCategory = {};
|
||||
jsonCategory[attrIdCategory] = row.getAttribute(attrIdCategory);
|
||||
jsonCategory[attrIdProductCategory] = row.getAttribute(attrIdProductCategory);
|
||||
jsonCategory[flagCode] = DOM.getElementValueCurrent(textareaCode);
|
||||
jsonCategory[flagName] = DOM.getElementValueCurrent(textareaName);
|
||||
jsonCategory[flagDescription] = DOM.getElementValueCurrent(textareaDescription);
|
||||
jsonCategory[flagAccessLevelRequired] = tdAccessLevel.getAttribute(flagAccessLevelRequired);
|
||||
jsonCategory[attrIdAccessLevel] = tdAccessLevel.getAttribute(attrIdAccessLevel);
|
||||
// jsonCategory[flagAccessLevelRequired] = tdAccessLevel.getAttribute(flagAccessLevelRequired);
|
||||
jsonCategory[attrIdAccessLevel] = DOM.getElementValueCurrent(tdAccessLevel);
|
||||
jsonCategory[flagActive] = DOM.getElementValueCurrent(inputActive);
|
||||
jsonCategory[flagDisplayOrder] = sliderDisplayOrder.getAttribute(attrValueCurrent);
|
||||
return jsonCategory;
|
||||
}
|
||||
initialiseRowNew(row) {
|
||||
if (row == null) return;
|
||||
let slidersDisplayOrder = document.querySelectorAll('td.' + flagDisplayOrder + ' input.' + flagSlider);
|
||||
let maxDisplayOrder = 0;
|
||||
slidersDisplayOrder.forEach((slider) => {
|
||||
maxDisplayOrder = Math.max(maxDisplayOrder, parseFloat(DOM.getElementValueCurrent(slider)));
|
||||
});
|
||||
let sliderDisplayOrder = row.querySelector('td.' + flagDisplayOrder + ' .' + flagSlider);
|
||||
DOM.setElementValuesCurrentAndPrevious(sliderDisplayOrder, maxDisplayOrder + 1);
|
||||
}
|
||||
|
||||
hookupTableMain() {
|
||||
super.hookupTableMain();
|
||||
@@ -100,6 +104,7 @@ export default class PageStoreProductCategories extends TableBasePage {
|
||||
this.hookupInputsActiveTable();
|
||||
}
|
||||
|
||||
/*
|
||||
isDirtyRow(row) {
|
||||
if (row == null) return false;
|
||||
console.log("Product Category isDirtyRow");
|
||||
@@ -115,16 +120,19 @@ export default class PageStoreProductCategories extends TableBasePage {
|
||||
DOM.handleDirtyElement(row, isDirty);
|
||||
return isDirty;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
leave() {
|
||||
super.leave();
|
||||
}
|
||||
|
||||
/*
|
||||
getFiltersDefaults() {
|
||||
filters = {};
|
||||
filters.flagIsNotEmpty = true;
|
||||
filters.flagActive = true;
|
||||
return filters;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
@@ -1,472 +1,551 @@
|
||||
|
||||
import API from "../../api.js";
|
||||
import BusinessObjects from "../../lib/business_objects.js";
|
||||
import DOM from "../../dom.js";
|
||||
import Events from "../../lib/events.js";
|
||||
import BasePage from "../base.js";
|
||||
import TableBasePage from "../base_table.js";
|
||||
import Utils from "../../lib/utils.js";
|
||||
import Validation from "../../lib/validation.js";
|
||||
import StoreTableMixinPage from "./mixin_table.js";
|
||||
|
||||
|
||||
export default class PageStoreProductPermutations extends BasePage {
|
||||
export default class PageStoreProductPermutations extends TableBasePage {
|
||||
static hash = hashPageStoreProductPermutations;
|
||||
callFilterTableContent = API.getProductPermutationsByFilters;
|
||||
callSaveTableContent = API.saveProductPermutations;
|
||||
|
||||
constructor(router) {
|
||||
super(router);
|
||||
this.storeMixin = new StoreTableMixinPage(this);
|
||||
}
|
||||
|
||||
initialize() {
|
||||
this.sharedInitialize();
|
||||
hookupFilters();
|
||||
hookupButtonsSaveCancel();
|
||||
hookupTableMain();
|
||||
hookupOverlayConfirm(savePermutations);
|
||||
}
|
||||
|
||||
hookupFilters() {
|
||||
Events.initialiseEventHandler(idFilterCategory, flagInitialised, function(filterCategory) {
|
||||
console.log("hooking up filter category");
|
||||
/*
|
||||
listCategories.forEach(function(category) {
|
||||
console.log('adding category: ', category.value, category.text);
|
||||
/*
|
||||
let option = document.createElement('option');
|
||||
option.value = category.value;
|
||||
option.text = category.text;
|
||||
*
|
||||
filterCategory.appendChild(document.createElement('<option>', category));
|
||||
});
|
||||
console.log(listCategories);
|
||||
*/
|
||||
filterCategory.addEventListener("change", function(event) {
|
||||
loadPermutations();
|
||||
});
|
||||
console.log("hooked up filter category");
|
||||
});
|
||||
|
||||
Events.initialiseEventHandler(idFilterProduct, flagInitialised, function(filterProduct) {
|
||||
listProducts.forEach(function(product) {
|
||||
if (product[attrIdCategory] != getElementCurrentValue(document.querySelectorAll(idFilterCategory))) return;
|
||||
/*
|
||||
let option = document.createElement('option');
|
||||
option.value = product.value;
|
||||
option.text = product.text;
|
||||
*/
|
||||
filterProduct.appendChild(document.createElement('<option>', product));
|
||||
});
|
||||
filterProduct.addEventListener("change", function(event) {
|
||||
loadPermutations();
|
||||
});
|
||||
});
|
||||
|
||||
Events.initialiseEventHandler(idFilterIsOutOfStock, flagInitialised, function(filterIsOutOfStock) {
|
||||
filterIsOutOfStock.addEventListener("change", function(event) {
|
||||
loadPermutations();
|
||||
});
|
||||
});
|
||||
|
||||
Events.initialiseEventHandler(idFilterQuantityMin, flagInitialised, function(filterQuantityMin) {
|
||||
filterQuantityMin.addEventListener("change", function(event) {
|
||||
loadPermutations();
|
||||
});
|
||||
});
|
||||
|
||||
Events.initialiseEventHandler(idFilterQuantityMax, flagInitialised, function(filterQuantityMax) {
|
||||
filterQuantityMax.addEventListener("change", function(event) {
|
||||
loadPermutations();
|
||||
this.sharedHookupFilters();
|
||||
this.hookupFilterProductCategory();
|
||||
this.hookupFilterProduct();
|
||||
this.hookupFilterOutOfStock();
|
||||
this.hookupFilterMinStock();
|
||||
this.hookupFilterMaxStock();
|
||||
}
|
||||
hookupFilterProductCategory() {
|
||||
this.hookupFilter(flagProductCategory, (event, filterCategory) => {
|
||||
// loadPermutations();
|
||||
// let wasDirtyFilter = filterCategory.classList.contains(flagDirty);
|
||||
PageStoreProductPermutations.isDirtyFilter(filterCategory);
|
||||
let isDirtyFilter = filterCategory.classList.contains(flagDirty);
|
||||
let idProductCategory = DOM.getElementValueCurrent(filterCategory);
|
||||
let products = productCategories[idProductCategory];
|
||||
let filterProduct = document.querySelector(idFormFilters + ' .' + flagProduct);
|
||||
let idProductPrevious = filterProduct.getAttribute(attrValuePrevious);
|
||||
filterProduct.innerHTML = '';
|
||||
let optionJson, option;
|
||||
option = DOM.createOption(null);
|
||||
filterProduct.appendChild(option);
|
||||
products.forEach((product) => {
|
||||
optionJson = BusinessObjects.getOptionJsonFromObjectJson(product, idProductPrevious);
|
||||
option = DOM.createOption(optionJson);
|
||||
filterProduct.appendChild(option);
|
||||
});
|
||||
filterProduct.dispatchEvent(new Event('change'));
|
||||
});
|
||||
}
|
||||
hookupFilterProduct() {
|
||||
this.hookupFilter(flagProduct);
|
||||
}
|
||||
hookupFilterOutOfStock() {
|
||||
this.hookupFilter(flagIsOutOfStock);
|
||||
}
|
||||
hookupFilterMinStock() {
|
||||
this.hookupFilter(flagQuantityMin);
|
||||
}
|
||||
hookupFilterMaxStock() {
|
||||
this.hookupFilter(flagQuantityMax);
|
||||
}
|
||||
|
||||
loadPermutations() {
|
||||
|
||||
let elForm = document.querySelectorAll(idFormFiltersPermutations);
|
||||
let ajaxData = {};
|
||||
ajaxData[keyForm] = convertForm2JSON(elForm);
|
||||
ajaxData.csrf_token = ajaxData[keyForm].csrf_token;
|
||||
loadRowTable(rowJson) {
|
||||
/*
|
||||
ajaxData[attrIdCategory] = getElementCurrentValue(document.querySelectorAll(idFilterCategory));
|
||||
ajaxData[attrIdProduct] = getElementCurrentValue(document.querySelectorAll(idFilterProduct));
|
||||
ajaxData[flagIsOutOfStock] = getElementCurrentValue(document.querySelectorAll(idFilterIsOutOfStock));
|
||||
ajaxData[flagQuantityMin] = getElementCurrentValue(document.querySelectorAll(idFilterQuantityMin));
|
||||
ajaxData[flagQuantityMax] = getElementCurrentValue(document.querySelectorAll(idFilterQuantityMax));
|
||||
if (rowJson == null) return;
|
||||
let tableMain = this.getTableMain();
|
||||
let row = _rowBlank.cloneNode(true);
|
||||
row.classList.remove(flagRowNew);
|
||||
console.log("applying data row: ", rowJson);
|
||||
let dllCategory = row.querySelector('td.' + flagProductCategory + ' select');
|
||||
dllCategory.value = rowJson[attrIdProductCategory];
|
||||
let ddlProduct = row.querySelector('td.' + flagProduct + ' select');
|
||||
let optionJson, option;
|
||||
listProducts.forEach(function(product) {
|
||||
if (product[attrIdProductCategory] != rowJson[attrIdProductCategory]) return;
|
||||
optionJson = BusinessObjects.getOptionJsonFromObjectJson(product);
|
||||
option = DOM.createOption(optionJson, rowJson[attrIdProduct]);
|
||||
ddlProduct.appendChild(option);
|
||||
});
|
||||
ddlProduct.value = rowJson[attrIdProduct];
|
||||
row.querySelector('td.' + flagProductVariations + ' textarea').value = rowJson[flagProductVariations];
|
||||
let tdProductVariations = row.querySelector('td.' + flagProductVariations);
|
||||
let textareaProductVariations = tdProductVariations.querySelector('textarea');
|
||||
DOM.setElementValuesCurrentAndPrevious(textareaProductVariations, rowJson[flagProductVariations]);
|
||||
let thProductVariations = row.querySelector('td.' + flagProductVariations);
|
||||
if (!thProductVariations.classList.contains(flagCollapsed)) tdProductVariations.classList.remove(flagCollapsed);
|
||||
let inputDescription = row.querySelector('td.' + flagDescription + ' textarea');
|
||||
DOM.setElementValuesCurrentAndPrevious(inputDescription, rowJson[flagDescription]);
|
||||
let inputCostLocal = row.querySelector('td.' + flagCostLocal + ' input');
|
||||
DOM.setElementValuesCurrentAndPrevious(inputCostLocal, rowJson[flagCostLocal]);
|
||||
let tdCurrencyCost = row.querySelector('td.' + flagCurrencyCost);
|
||||
DOM.setElementAttributesValuesCurrentAndPrevious(tdCurrencyCost, rowJson[flagCurrencyCost]);
|
||||
let ddlCurrencyCost = tdCurrencyCost.querySelector('select');
|
||||
DOM.setElementValuesCurrentAndPrevious(ddlCurrencyCost, rowJson[flagCurrencyCost]);
|
||||
let inputProfitLocalMin = row.querySelector('td.' + flagProfitLocalMin + ' input');
|
||||
DOM.setElementValuesCurrentAndPrevious(inputProfitLocalMin, rowJson[flagProfitLocalMin]);
|
||||
let inputLatencyManufactureDays = row.querySelector('td.' + flagLatencyManufactureDays + ' input');
|
||||
DOM.setElementValuesCurrentAndPrevious(inputLatencyManufactureDays, rowJson[flagLatencyManufactureDays]);
|
||||
let inputQuantityStock = row.querySelector('td.' + flagQuantityStock + ' input');
|
||||
DOM.setElementValuesCurrentAndPrevious(inputQuantityStock, rowJson[flagQuantityStock]);
|
||||
let inputQuantityMin = row.querySelector('td.' + flagQuantityMin + ' input');
|
||||
DOM.setElementValuesCurrentAndPrevious(inputQuantityMin, rowJson[flagQuantityMin]);
|
||||
let inputQuantityMax = row.querySelector('td.' + flagQuantityMax + ' input');
|
||||
DOM.setElementValuesCurrentAndPrevious(inputQuantityMax, rowJson[flagQuantityMax]);
|
||||
let inputQuantityStep = row.querySelector('td.' + flagCountUnitMeasurementPerQuantityStep + ' input');
|
||||
DOM.setElementValuesCurrentAndPrevious(inputQuantityStep, rowJson[flagCountUnitMeasurementPerQuantityStep]);
|
||||
|
||||
|
||||
|
||||
row.querySelector('td.' + flagQuantityStock + ' input').value = rowJson[flagQuantityStock];
|
||||
row.querySelector('td.' + flagQuantityMin + ' input').value = rowJson[flagQuantityMin];
|
||||
row.querySelector('td.' + flagQuantityMax + ' input').value = rowJson[flagQuantityMax];
|
||||
row.querySelector('td.' + flagCostLocal).innerHTML = rowJson[flagCostLocal];
|
||||
row.setAttribute(attrIdProductCategory, rowJson[flagProductCategory]);
|
||||
row.setAttribute(attrIdProduct, rowJson[flagProduct]);
|
||||
row.setAttribute(attrIdProductPermutation, rowJson[attrIdProductPermutation]);
|
||||
let tbody = tableMain.querySelector('tbody');
|
||||
tbody.appendChild(row);
|
||||
*/
|
||||
|
||||
console.log('ajaxData:'); console.log(ajaxData);
|
||||
|
||||
ajaxJSONData('permutations', mapHashToController(hashPageStorePermutationsPost), ajaxData, callbackLoadPermutations, false, {"X-CSRFToken": ajaxData.csrf_token});
|
||||
}
|
||||
getJsonRow(row) {
|
||||
if (row == null) return;
|
||||
let tdProductCategory = row.querySelector('td.' + flagProductCategory);
|
||||
let tdProduct = row.querySelector('td.' + flagProduct);
|
||||
let tdProductVariations = row.querySelector('td.' + flagProductVariations);
|
||||
let inputDescription = row.querySelector('td.' + flagDescription + ' textarea');
|
||||
let inputCostLocal = row.querySelector('td.' + flagCostLocal + ' input');
|
||||
let tdCurrencyCost = row.querySelector('td.' + flagCurrencyCost);
|
||||
let inputProfitLocalMin = row.querySelector('td.' + flagProfitLocalMin + ' input');
|
||||
let inputLatencyManufactureDays = row.querySelector('td.' + flagLatencyManufactureDays + ' input');
|
||||
let inputQuantityStock = row.querySelector('td.' + flagQuantityStock + ' input');
|
||||
let inputQuantityMin = row.querySelector('td.' + flagQuantityMin + ' input');
|
||||
let inputQuantityMax = row.querySelector('td.' + flagQuantityMax + ' input');
|
||||
let inputQuantityStep = row.querySelector('td.' + flagCountUnitMeasurementPerQuantityStep + ' input');
|
||||
let tdUnitMeasurementQuantity = row.querySelector('td.' + flagUnitMeasurementQuantity);
|
||||
let checkboxIsSubscription = row.querySelector('td.' + flagIsSubscription + ' input');
|
||||
let inputCountIntervalRecurrence = row.querySelector('td.' + flagCountUnitMeasurementIntervalRecurrence + ' input');
|
||||
let tdUnitMeasurementIntervalRecurrence = row.querySelector('td.' + flagUnitMeasurementIntervalRecurrence);
|
||||
let inputIdStripeProduct = row.querySelector('td.' + flagIdStripeProduct + ' input');
|
||||
let checkboxDoesExpireFasterOnceUnsealed = row.querySelector('td.' + flagDoesExpireFasterOnceUnsealed + ' input');
|
||||
let inputCountIntervalExpirationUnsealed = row.querySelector('td.' + flagCountUnitMeasurementIntervalExpirationUnsealed + ' input');
|
||||
let tdUnitMeasurementIntervalExpirationUnsealed = row.querySelector('td.' + flagUnitMeasurementIntervalExpirationUnsealed);
|
||||
let checkboxActive = row.querySelector('td.' + flagActive + ' input');
|
||||
|
||||
callbackLoadPermutations(response) {
|
||||
|
||||
console.log('ajax:'); console.log(response.data);
|
||||
|
||||
let table = document.querySelectorAll(idTableMain);
|
||||
let bodyTable, row, dllCategory, ddlProduct;
|
||||
|
||||
// table.querySelector('tr').remove(); // :not(.' + flagRowNew + ')
|
||||
bodyTable = table.querySelector('tbody');
|
||||
bodyTable.querySelector('tr').remove();
|
||||
|
||||
response.data.forEach(function(dataRow) {
|
||||
row = _rowBlank.cloneNode(true);
|
||||
row = document.querySelectorAll(row);
|
||||
row.classList.remove(flagRowNew);
|
||||
console.log("applying data row: ", dataRow);
|
||||
dllCategory = row.querySelector('td.' + flagCategory + ' select');
|
||||
dllCategory.value = dataRow[attrIdCategory];
|
||||
ddlProduct = row.querySelector('td.' + flagProduct + ' select');
|
||||
listProducts.forEach(function(product) {
|
||||
if (product[attrIdCategory] != dataRow[attrIdCategory]) return;
|
||||
ddlProduct.appendChild(document.createElement('<option>', product));
|
||||
});
|
||||
ddlProduct.value = dataRow[attrIdProduct];
|
||||
row.querySelector('td.' + flagVariations + ' textarea').value = dataRow[flagVariations];
|
||||
row.querySelector('td.' + flagQuantityStock + ' input').value = dataRow[flagQuantityStock];
|
||||
row.querySelector('td.' + flagQuantityMin + ' input').value = dataRow[flagQuantityMin];
|
||||
row.querySelector('td.' + flagQuantityMax + ' input').value = dataRow[flagQuantityMax];
|
||||
row.querySelector('td.' + flagCostLocalVATIncl).innerHTML = dataRow[flagCostLocalVATIncl];
|
||||
row.attr(attrIdCategory, dataRow[flagCategory]);
|
||||
row.attr(attrIdProduct, dataRow[flagProduct]);
|
||||
row.attr(attrIdPermutation, dataRow[attrIdPermutation]);
|
||||
bodyTable.appendChild(row);
|
||||
});
|
||||
let jsonRow = {};
|
||||
jsonRow[attrIdProductPermutation] = row.getAttribute(attrIdProductPermutation);
|
||||
jsonRow[attrIdProductCategory] = tdProductCategory.getAttribute(attrValueCurrent);
|
||||
jsonRow[attrIdProduct] = tdProduct.getAttribute(attrValueCurrent);
|
||||
jsonRow[flagProductVariations] = tdProductVariations.getAttribute(attrValueCurrent);
|
||||
jsonRow[flagHasVariations] = jsonRow[flagProductVariations] != '';
|
||||
jsonRow[flagDescription] = inputDescription.getAttribute(attrValueCurrent);
|
||||
jsonRow[flagCostLocal] = inputCostLocal.getAttribute(attrValueCurrent);
|
||||
jsonRow[flagCurrencyCost] = tdCurrencyCost.getAttribute(attrValueCurrent);
|
||||
jsonRow[flagProfitLocalMin] = inputProfitLocalMin.getAttribute(attrValueCurrent);
|
||||
jsonRow[flagLatencyManufactureDays] = inputLatencyManufactureDays.getAttribute(attrValueCurrent);
|
||||
jsonRow[flagQuantityStock] = inputQuantityStock.getAttribute(attrValueCurrent);
|
||||
jsonRow[flagQuantityMin] = inputQuantityMin.getAttribute(attrValueCurrent);
|
||||
jsonRow[flagQuantityMax] = inputQuantityMax.getAttribute(attrValueCurrent);
|
||||
jsonRow[flagCountUnitMeasurementPerQuantityStep] = inputQuantityStep.getAttribute(attrValueCurrent);
|
||||
jsonRow[flagUnitMeasurementQuantity] = tdUnitMeasurementQuantity.getAttribute(attrValueCurrent);
|
||||
jsonRow[flagIsSubscription] = checkboxIsSubscription.getAttribute(attrValueCurrent);
|
||||
jsonRow[flagCountUnitMeasurementIntervalRecurrence] = inputCountIntervalRecurrence.getAttribute(attrValueCurrent);
|
||||
jsonRow[flagUnitMeasurementIntervalRecurrence] = tdUnitMeasurementIntervalRecurrence.getAttribute(attrValueCurrent);
|
||||
jsonRow[flagIdStripeProduct] = inputIdStripeProduct.getAttribute(attrValueCurrent);
|
||||
jsonRow[flagDoesExpireFasterOnceUnsealed] = checkboxDoesExpireFasterOnceUnsealed.getAttribute(attrValueCurrent);
|
||||
jsonRow[flagCountUnitMeasurementIntervalExpirationUnsealed] = inputCountIntervalExpirationUnsealed.getAttribute(attrValueCurrent);
|
||||
jsonRow[flagUnitMeasurementIntervalExpirationUnsealed] = tdUnitMeasurementIntervalExpirationUnsealed.getAttribute(attrValueCurrent);
|
||||
jsonRow[flagActive] = checkboxActive.getAttribute(attrValueCurrent);
|
||||
return jsonRow;
|
||||
}
|
||||
|
||||
hookupButtonsSaveCancel() {
|
||||
Events.initialiseEventHandler(idButtonSave, flagInitialised, function(button) {
|
||||
button.addEventListener("click", function(event) {
|
||||
event.stopPropagation();
|
||||
showOverlayConfirm();
|
||||
});
|
||||
});
|
||||
// let parentSave = btnSave.closest('div.' + flagColumn);
|
||||
// parentSave.classList.add(flagCollapsed);
|
||||
|
||||
Events.initialiseEventHandler(idButtonCancel, flagInitialised, function(button) {
|
||||
button.addEventListener("click", function(event) {
|
||||
event.stopPropagation();
|
||||
loadPermutations();
|
||||
});
|
||||
});
|
||||
// let parentCancel = btnCancel.closest('div.' + flagColumn);
|
||||
// parentCancel.classList.add(flagCollapsed);
|
||||
|
||||
Events.initialiseEventHandler(idButtonCancel, flagInitialised, function(button) {
|
||||
button.addEventListener("click", function(event) {
|
||||
event.stopPropagation();
|
||||
let table = document.querySelectorAll(idTableMain);
|
||||
let row = _rowBlank.cloneNode(true);
|
||||
row = document.querySelectorAll(row);
|
||||
row.classList.remove(flagRowNew);
|
||||
let ddlCategory = row.querySelector('td.' + flagCategory + ' select');
|
||||
let idCategory = getElementCurrentValue(document.querySelectorAll(idFilterCategory));
|
||||
idCategory = (idCategory == 0) ? idCategoryDefault : idCategory;
|
||||
let ddlProduct = row.querySelector('td.' + flagProduct + ' select');
|
||||
let products = productsByCategory[idCategory];
|
||||
products.forEach(function(product) {
|
||||
ddlProduct.appendChild(document.createElement('<option>', product));
|
||||
});
|
||||
table.querySelector('tbody').appendChild(row);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
savePermutations() {
|
||||
|
||||
let permutations = getPermutations(true);
|
||||
|
||||
if (permutations.length == 0) {
|
||||
showOverlayError('No permutations to save');
|
||||
return;
|
||||
initialiseRowNew(row) {
|
||||
let ddlCategoryFilter = document.querySelector(idFormFilters + ' #' + attrIdProductCategory);
|
||||
let idProductCategoryFilter = DOM.getElementValueCurrent(ddlCategoryFilter);
|
||||
let hasCategoryFilter = !(Validation.isEmpty(idProductCategoryFilter) || idProductCategoryFilter == '0');
|
||||
let ddlProductFilter = document.querySelector(idFormFilters + ' #' + attrIdProduct);
|
||||
let idProductFilter = DOM.getElementValueCurrent(ddlProductFilter);
|
||||
let hasProductFilter = !(Validation.isEmpty(idProductFilter) || idProductFilter == '0');
|
||||
console.log("initialiseRowNew: ", row);
|
||||
console.log({ddlCategoryFilter, idProductCategoryFilter, hasCategoryFilter, ddlProductFilter, idProductFilter, hasProductFilter});
|
||||
if (!hasCategoryFilter && !hasProductFilter) return;
|
||||
if (hasCategoryFilter) {
|
||||
let ddlCategory = row.querySelector('td.' + flagProductCategory + ' select');
|
||||
DOM.setElementValuesCurrentAndPrevious(ddlCategory, idProductCategoryFilter);
|
||||
this.handleChangeProductCategoryDdl(null, ddlCategory);
|
||||
}
|
||||
if (hasProductFilter) {
|
||||
let ddlProduct = row.querySelector('td.' + flagProduct + ' select');
|
||||
DOM.setElementValuesCurrentAndPrevious(ddlProduct, idProductFilter);
|
||||
}
|
||||
|
||||
let ajaxData = {};
|
||||
ajaxData[keyPermutations] = permutations;
|
||||
ajaxData[keyForm] = convertForm2JSON(elForm);
|
||||
ajaxData.csrf_token = ajaxData[keyForm].csrf_token;
|
||||
ajaxData.comment = document.querySelectorAll(idTextareaConfirm).value;
|
||||
|
||||
console.log('ajaxData:'); console.log(ajaxData);
|
||||
ajaxJSONData('permutations', mapHashToController(hashPageStorePermutationsPost), ajaxData, callbackLoadPermutations, false, {});
|
||||
}
|
||||
|
||||
getPermutations(dirtyOnly) {
|
||||
let table = document.querySelectorAll(idTableMain);
|
||||
let permutations = [];
|
||||
let row, permutation, ddlCategory, ddlProduct, variations, quantityStock, quantityMin, quantityMax, costLocal;
|
||||
table.querySelector('tbody tr').each(function(index, row) {
|
||||
row = document.querySelectorAll(row);
|
||||
if (dirtyOnly && !row.classList.contains(flagDirty)) return;
|
||||
|
||||
ddlCategory = row.querySelector('td.' + flagCategory + ' select');
|
||||
ddlProduct = row.querySelector('td.' + flagProduct + ' select');
|
||||
variations = row.querySelector('td.' + flagVariations + ' textarea');
|
||||
quantityStock = row.querySelector('td.' + flagQuantityStock + ' input');
|
||||
quantityMin = row.querySelector('td.' + flagQuantityMin + ' input');
|
||||
quantityMax = row.querySelector('td.' + flagQuantityMax + ' input');
|
||||
|
||||
permutation = {};
|
||||
permutation[attrIdCategory] = ddlCategory.attr(attrValueCurrent);
|
||||
permutation[attrIdProduct] = ddlProduct.attr(attrValueCurrent);
|
||||
permutation[attrIdPermutation] = row.attr(attrIdPermutation)
|
||||
permutation[flagVariations] = variations.attr(attrValueCurrent);
|
||||
permutation[flagQuantityStock] = quantityStock.attr(attrValueCurrent);
|
||||
permutation[flagQuantityMin] = quantityMin.attr(attrValueCurrent);
|
||||
permutation[flagQuantityMax] = quantityMax.attr(attrValueCurrent);
|
||||
permutations.push(permutation);
|
||||
});
|
||||
return permutations;
|
||||
}
|
||||
|
||||
hookupTableMain() {
|
||||
Events.initialiseEventHandler(idTableMain, flagInitialised, function(table) {
|
||||
|
||||
table.querySelectorAll('td.' + flagCategory + ' select').addEventListener("change", function(event) {
|
||||
handleChangeInputPermutations(this);
|
||||
ddlCategory = this;
|
||||
row = getRowFromElement(ddlCategory);
|
||||
ddlProduct = row.querySelector('td.' + flagProduct + ' select');
|
||||
ddlProduct.querySelector('option').remove();
|
||||
ddlProduct.appendChild(document.createElement('<option>', {value: '', text: 'Select Product'}));
|
||||
listProducts.forEach(function(product) {
|
||||
if (product[attrIdCategory] != getElementCurrentValue(ddlCategory)) return;
|
||||
ddlProduct.appendChild(document.createElement('<option>', product));
|
||||
});
|
||||
handleChangeInputPermutations(ddlProduct);
|
||||
});
|
||||
|
||||
table.querySelectorAll("change", 'td.' + flagProduct + ' select' + ',' + 'td.' + flagQuantityStock + ' input' + ',' + 'td.' + flagQuantityMin + ' input' + ',' + 'td.' + flagQuantityMax + ' input').addEventListener("change", function(event) {
|
||||
handleChangeInputPermutations(this);
|
||||
});
|
||||
|
||||
table.querySelectorAll("click", 'td.' + flagVariations + ' textarea').addEventListener("change", function(event) {
|
||||
event.stopPropagation();
|
||||
handleClickPermutationsInputVariations(this);
|
||||
});
|
||||
|
||||
table.querySelectorAll("click", 'td.' + flagDetail + ' button').addEventListener("change", function(event) {
|
||||
event.stopPropagation();
|
||||
console.log("not implemented error: detail clicked");
|
||||
});
|
||||
|
||||
table.querySelectorAll("click", 'td.' + flagVariations + ' button.' + flagAdd).addEventListener("change", function(event) {
|
||||
event.stopPropagation();
|
||||
handleClickPermutationsVariationsButtonAdd(this);
|
||||
});
|
||||
});
|
||||
|
||||
// cache new row for cloning
|
||||
let rowBlankTemp = table.querySelector('tr.' + flagRowNew);
|
||||
console.log("row blank temp: ", rowBlankTemp);
|
||||
_rowBlank = rowBlankTemp.cloneNode(true);
|
||||
table.querySelectorAll('tr.' + flagRowNew).forEach(function(row) {
|
||||
row.remove();
|
||||
});
|
||||
super.hookupTableMain();
|
||||
this.hookupProductCategoryFields();
|
||||
this.hookupProductFields();
|
||||
this.hookupProductVariationFields();
|
||||
this.hookupDescriptionTextareas();
|
||||
this.hookupCostFields();
|
||||
this.hookupLatencyManufactureInputs();
|
||||
this.hookupQuantityFields();
|
||||
this.hookupSubscriptionFields();
|
||||
this.hookupIdStripeProductInputs();
|
||||
this.hookupExpirationFields();
|
||||
this.hookupActiveCheckboxes();
|
||||
}
|
||||
|
||||
handleChangeInputPermutations(element) {
|
||||
console.log("handleChangeInputPermutations");
|
||||
console.log("element value:", element.value);
|
||||
let row = getRowFromElement(element);
|
||||
let formFilters = document.querySelector(idFormFiltersPermutations);
|
||||
let buttonCancel = formFilters.querySelector(idButtonCancel);
|
||||
let buttonSave = formFilters.querySelector(idButtonSave);
|
||||
let wasDirty = isElementDirty(element);
|
||||
|
||||
if (objJQuery.classList.contains(flagVariations)) {
|
||||
element.setAttribute(attrValueCurrent, getProductVariationsText(element));
|
||||
} else {
|
||||
element.setAttribute(attrValueCurrent, getElementCurrentValue(element));
|
||||
}
|
||||
let isDirty = isElementDirty(element);
|
||||
|
||||
if (wasDirty != isDirty) {
|
||||
isRowDirty(row);
|
||||
let permutationsDirty = getPermutations(true);
|
||||
if (Validation.isEmpty(permutationsDirty)) {
|
||||
buttonCancel.classList.add(flagCollapsed);
|
||||
buttonSave.classList.add(flagCollapsed);
|
||||
} else {
|
||||
buttonCancel.classList.remove(flagCollapsed);
|
||||
buttonSave.classList.remove(flagCollapsed);
|
||||
}
|
||||
}
|
||||
hookupProductCategoryFields() {
|
||||
this.hookupTableCellDdlPreviews(idTableMain + ' td.' + flagProductCategory, Utils.getListFromDict(productCategories), (event, element) => { this.hookupProductCategoryDdls(event, element); });
|
||||
}
|
||||
|
||||
isElementDirty(element) {
|
||||
let isDirty = element.attr(attrValuePrevious) != element.attr(attrValueCurrent);
|
||||
let cell = getCellFromElement(element);
|
||||
if (isDirty) {
|
||||
element.classList.add(flagDirty);
|
||||
cell.classList.add(flagDirty);
|
||||
} else {
|
||||
element.classList.remove(flagDirty);
|
||||
cell.classList.remove(flagDirty);
|
||||
}
|
||||
return isDirty;
|
||||
hookupProductCategoryDdls(ddlSelector) {
|
||||
this.hookupChangeHandlerTableCells(ddlSelector, (event, element) => { this.handleChangeProductCategoryDdl(event, element); });
|
||||
}
|
||||
|
||||
isRowDirty(row) {
|
||||
let ddlCategory = row.querySelector('td.' + flagCategory + ' select');
|
||||
handleChangeProductCategoryDdl(event, ddlCategory) {
|
||||
this.handleChangeTableCellDdl(event, ddlCategory);
|
||||
let idProductCategorySelected = DOM.getElementValueCurrent(ddlCategory);
|
||||
let row = DOM.getRowFromElement(ddlCategory);
|
||||
let tdProduct = row.querySelector('td.' + flagProduct);
|
||||
tdProduct.dispatchEvent(new Event('click'));
|
||||
let ddlProduct = row.querySelector('td.' + flagProduct + ' select');
|
||||
let variations = row.querySelector('td.' + flagVariations + ' textarea');
|
||||
let quantityStock = row.querySelector('td.' + flagQuantityStock + ' input');
|
||||
let quantityMin = row.querySelector('td.' + flagQuantityMin + ' input');
|
||||
let quantityMax = row.querySelector('td.' + flagQuantityMax + ' input');
|
||||
|
||||
// return isElementDirty(ddlCategory) || isElementDirty(ddlProduct) || isElementDirty(variations) || isElementDirty(quantityStock) || isElementDirty(quantityMin) || isElementDirty(quantityMax);
|
||||
let isDirty = ddlCategory.classList.contains(flagDirty) || ddlProduct.classList.contains(flagDirty) || variations.classList.contains(flagDirty) ||
|
||||
quantityStock.classList.contains(flagDirty) || quantityMin.classList.contains(flagDirty) || quantityMax.classList.contains(flagDirty);
|
||||
if (isDirty) {
|
||||
row.classList.add(flagDirty);
|
||||
} else {
|
||||
row.classList.remove(flagDirty);
|
||||
}
|
||||
return isDirty;
|
||||
ddlProduct.innerHTML = '';
|
||||
ddlProduct.appendChild(DOM.createOption(null));
|
||||
let optionJson, option;
|
||||
Utils.getListFromDict(products).forEach((product) => {
|
||||
if (product[attrIdProductCategory] != idProductCategorySelected) return;
|
||||
optionJson = BusinessObjects.getOptionJsonFromObjectJson(product);
|
||||
option = DOM.createOption(optionJson);
|
||||
ddlProduct.appendChild(option);
|
||||
});
|
||||
this.handleChangeTableCellDdl(event, ddlProduct);
|
||||
}
|
||||
|
||||
getProductVariationsText(element) {
|
||||
element = document.querySelectorAll(element);
|
||||
/*
|
||||
let value = element.value;
|
||||
let variations = value.split('\n');
|
||||
variations = variations.map(function(variation) {
|
||||
return variation.trim();
|
||||
});
|
||||
variations = variations.filter(function(variation) {
|
||||
return variation.length > 0;
|
||||
});
|
||||
*/
|
||||
let variations = dictVariations[element.attr(attrIdVariation)].map((variation, index) => {
|
||||
return variation[keyNameVariationType] + ': ' + variation[keyNameVariation];
|
||||
});
|
||||
return variations.join(',\n');
|
||||
hookupProductFields() {
|
||||
this.hookupTableCellDdlPreviews(idTableMain + ' td.' + flagProduct, Utils.getListFromDict(products));
|
||||
}
|
||||
|
||||
getElementProductVariations(element) {
|
||||
element = document.querySelectorAll(element);
|
||||
let variations = element.attr(attrValueCurrent);
|
||||
let objVariations = [];
|
||||
if (!Validation.isEmpty(variations)) {
|
||||
variations = variations.split(',');
|
||||
variations.forEach((variation) => {
|
||||
let parts = variation.split(':');
|
||||
if (parts.length == 2) {
|
||||
objVariations.push({
|
||||
[attrIdVariationType]: parts[0].trim(),
|
||||
[attrIdVariation]: parts[1].trim(),
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
return objVariations;
|
||||
hookupProductVariationFields() {
|
||||
this.hookupEventHandler("click", idTableMain + ' td.' + flagProductVariations + ' div', (event, element) => this.handleClickProductPermutationVariationsPreview(event, element));
|
||||
}
|
||||
|
||||
handleClickPermutationsInputVariations(element) {
|
||||
element = document.querySelectorAll(element);
|
||||
|
||||
let jsonVariation, jsonVariationType, tr, tdVariationType, variationType, attributesVariationType, tdNameVariation, nameVariation, attributesNameVariation, tdDelete, buttonDelete, tmpJsonVariation, tmpJsonVariationType;
|
||||
let variations = getElementProductVariations(element);
|
||||
let tblVariations = document.createElement("<table>");
|
||||
let thead = document.createElement("<thead>");
|
||||
tr = document.createElement("<tr>");
|
||||
let thVariationType = document.createElement("<th>", {
|
||||
text: 'Type',
|
||||
});
|
||||
let thNameVariation = document.createElement("<th>", {
|
||||
text: 'Name',
|
||||
});
|
||||
let buttonAdd = document.createElement("<button>", {
|
||||
class: flagAdd,
|
||||
text: '+',
|
||||
});
|
||||
let thAddDelete = document.createElement("<th>");
|
||||
handleClickProductPermutationVariationsPreview(event, element) {
|
||||
this.toggleProductPermutationVariationsColumnCollapsed(false);
|
||||
let permutationVariations = this.getElementProductVariations(element);
|
||||
let tblVariations = document.createElement("table");
|
||||
tblVariations.classList.add(flagProductVariations);
|
||||
let thead = document.createElement("thead");
|
||||
let tr = document.createElement("tr");
|
||||
let thVariationType = document.createElement("th");
|
||||
thVariationType.textContent = 'Type';
|
||||
let thNameVariation = document.createElement("th");
|
||||
thNameVariation.textContent = 'Name';
|
||||
let buttonAdd = document.createElement("button");
|
||||
buttonAdd.classList.add(flagAdd);
|
||||
buttonAdd.textContent = '+';
|
||||
let thAddDelete = document.createElement("th");
|
||||
thAddDelete.appendChild(buttonAdd);
|
||||
tr.appendChild(thVariationType);
|
||||
tr.appendChild(thNameVariation);
|
||||
tr.appendChild(thAddDelete);
|
||||
thead.appendChild(tr);
|
||||
tblVariations.appendChild(thead);
|
||||
|
||||
let tbody = document.createElement("<tbody>");
|
||||
console.log('variations:', variations);
|
||||
/*
|
||||
if (Validation.isEmpty(variations)) {
|
||||
return;
|
||||
let tbody = document.createElement("tbody");
|
||||
console.log('variations:', permutationVariations);
|
||||
if (Validation.isEmpty(permutationVariations)) {
|
||||
permutationVariations = [PageStoreProductPermutations.createOptionUnselectedProductVariation()];
|
||||
}
|
||||
*/
|
||||
variations.forEach((variation, index) => {
|
||||
jsonVariationType = dictVariations[variation[attrIdVariationType]];
|
||||
jsonVariation = dictVariations[variation[attrIdVariation]];
|
||||
tdVariationType = document.createElement("<td>", {
|
||||
class: attrIdVariationType,
|
||||
else {
|
||||
permutationVariations.forEach((permutationVariation, index) => {
|
||||
this.addProductPermutationVariationRow(tbody, permutationVariation);
|
||||
});
|
||||
attributesVariationType = {
|
||||
class: attrIdVariationType,
|
||||
value: variation[attrIdVariationType],
|
||||
};
|
||||
attributesVariationType[attrValueCurrent] = jsonVariation[attrIdVariationType];
|
||||
attributesVariationType[attrValuePrevious] = jsonVariation[attrIdVariationType];
|
||||
variationType = document.createElement("<select>", attributesVariationType);
|
||||
listVariationTypes.forEach((idVariationType) => {
|
||||
tmpJsonVariationType = dictVariationTypes[idVariationType];
|
||||
variationType.appendChild(document.createElement('<option>', {
|
||||
value: jsonVariationType[attrIdVariationType],
|
||||
text: jsonVariationType[keyNameVariationType],
|
||||
selected: (idVariationType == jsonVariationType[attrIdVariationType]),
|
||||
}));
|
||||
});
|
||||
tdNameVariation = document.createElement("<td>", {
|
||||
class: attrIdVariation,
|
||||
});
|
||||
attributesNameVariation = {
|
||||
class: attrIdVariation,
|
||||
value: variation[attrIdVariation],
|
||||
};
|
||||
attributesNameVariation[attrValueCurrent] = jsonVariation[attrIdVariation];
|
||||
attributesNameVariation[attrValuePrevious] = jsonVariation[attrIdVariation];
|
||||
nameVariation = document.createElement("<select>", attributesNameVariation);
|
||||
listVariations.forEach((idVariation) => {
|
||||
tmpJsonVariation = dictVariations[idVariation];
|
||||
console.log("id_variation: ", idVariation);
|
||||
console.log("tmpJsonVariation: ", tmpJsonVariation);
|
||||
nameVariation.appendChild(document.createElement('<option>', {
|
||||
value: tmpJsonVariation[attrIdVariation],
|
||||
text: tmpJsonVariation[keyNameVariation],
|
||||
selected: (idVariation == jsonVariation[attrIdVariation]),
|
||||
}));
|
||||
});
|
||||
tdDelete = document.createElement("<td>", {
|
||||
class: flagDelete,
|
||||
});
|
||||
buttonDelete = document.createElement("<button>", {
|
||||
class: flagDelete,
|
||||
text: 'x',
|
||||
});
|
||||
tr = document.createElement("<tr>");
|
||||
tdVariationType.appendChild(variationType);
|
||||
tr.appendChild(tdVariationType);
|
||||
tdNameVariation.appendChild(nameVariation);
|
||||
tr.appendChild(tdNameVariation);
|
||||
tdDelete.appendChild(buttonDelete);
|
||||
tr.appendChild(tdDelete);
|
||||
tbody.appendChild(tr);
|
||||
});
|
||||
|
||||
}
|
||||
tblVariations.appendChild(tbody);
|
||||
let parent = element.parentElement;
|
||||
parent.innerHTML = '';
|
||||
parent.appendChild(tblVariations);
|
||||
console.log("tblVariations: ", tblVariations);
|
||||
let selectorButtonAdd = idTableMain + ' td.' + flagProductVariations + ' button.' + flagAdd;
|
||||
this.hookupEventHandler("click", selectorButtonAdd, this.handleClickButtonProductPermutationVariationsAdd);
|
||||
let selectorButtonDelete = idTableMain + ' td.' + flagProductVariations + ' button.' + flagDelete;
|
||||
this.hookupEventHandler("click", selectorButtonDelete, this.handleClickButtonProductPermutationVariationsDelete);
|
||||
}
|
||||
toggleProductPermutationVariationsColumnCollapsed(isCollapsed) {
|
||||
this.toggleColumnHasClassnameFlag(flagProductVariations, isCollapsed, flagCollapsed);
|
||||
}
|
||||
getElementProductVariations(element) {
|
||||
let permutationVariations = element.getAttribute(attrValueCurrent);
|
||||
let objVariations = [];
|
||||
let parts, new_variation, new_variation_type;
|
||||
if (!Validation.isEmpty(permutationVariations)) {
|
||||
permutationVariations = permutationVariations.split(',');
|
||||
permutationVariations.forEach((variation) => {
|
||||
parts = variation.split(':');
|
||||
if (parts.length == 2) {
|
||||
console.log("parts: ", parts);
|
||||
new_variation_type = productVariationTypes[parts[0].trim()];
|
||||
new_variation = productVariations[parts[1].trim()];
|
||||
objVariations.push({
|
||||
[flagProductVariationType]: new_variation_type,
|
||||
[flagProductVariation]: new_variation,
|
||||
});
|
||||
}
|
||||
else {
|
||||
console.log("error: invalid variation: ", variation);
|
||||
}
|
||||
});
|
||||
}
|
||||
return objVariations;
|
||||
}
|
||||
/*
|
||||
static createOptionUnselectedProductVariation() {
|
||||
return {
|
||||
[flagProductVariationType]: {
|
||||
[flagNameAttrOptionText]: [flagName],
|
||||
[flagNameAttrOptionValue]: [attrIdProductVariationType],
|
||||
[flagName]: 'Select Variation Type',
|
||||
[attrIdProductVariationType]: 0,
|
||||
},
|
||||
[flagProductVariation]: {
|
||||
[flagNameAttrOptionText]: [flagName],
|
||||
[flagNameAttrOptionValue]: [attrIdProductVariation],
|
||||
[flagName]: 'Select Variation',
|
||||
[attrIdProductVariation]: 0,
|
||||
},
|
||||
};
|
||||
}
|
||||
*/
|
||||
handleClickButtonProductPermutationVariationsAdd(event, element) {
|
||||
let row = DOM.getRowFromElement(element);
|
||||
let tbody = row.querySelector('tbody');
|
||||
let permutationVariation = PageStoreProductPermutations.createOptionUnselectedProductVariation();
|
||||
this.addProductPermutationVariationRow(tbody, permutationVariation);
|
||||
}
|
||||
addProductPermutationVariationRow(tbody, permutationVariation) {
|
||||
let productVariationType, optionProductVariationTypeJson, optionProductVariationType, productVariation, optionProductVariationJson, optionProductVariation;
|
||||
/*
|
||||
if (Validation.isEmpty(variations)) {
|
||||
return;
|
||||
}
|
||||
*/
|
||||
let productVariationKeys = Object.keys(productVariations);
|
||||
let productVariationTypeKeys = Object.keys(productVariationTypes);
|
||||
|
||||
console.log("permutationVariation: ", permutationVariation);
|
||||
let permutationVariationJson = permutationVariation[flagProductVariation];
|
||||
let permutationVariationTypeJson = permutationVariation[flagProductVariationType];
|
||||
|
||||
let tdVariationType = document.createElement("td");
|
||||
tdVariationType.classList.add(flagProductVariationType);
|
||||
DOM.setElementAttributesValuesCurrentAndPrevious(tdVariationType, permutationVariationTypeJson[attrIdProductVariationType]);
|
||||
|
||||
let ddlVariationType = document.createElement("select");
|
||||
ddlVariationType.classList.add(flagProductVariationType);
|
||||
DOM.setElementAttributesValuesCurrentAndPrevious(ddlVariationType, permutationVariationTypeJson[attrIdProductVariationType]);
|
||||
|
||||
optionProductVariationType = DOM.createOption(null);
|
||||
console.log("optionProductVariationType: ", optionProductVariationType);
|
||||
ddlVariationType.appendChild(optionProductVariationType);
|
||||
|
||||
productVariationTypeKeys.forEach((productVariationTypeKey) => {
|
||||
/*
|
||||
optionProductVariationType = document.createElement('option');
|
||||
optionProductVariationType.value = optionVariationType.value;
|
||||
optionProductVariationType.text = optionVariationType.text;
|
||||
*/
|
||||
productVariationType = productVariationTypes[productVariationTypeKey];
|
||||
optionProductVariationTypeJson = BusinessObjects.getOptionJsonFromObjectJson(productVariationType, permutationVariationTypeJson[attrIdProductVariationType]);
|
||||
optionProductVariationType = DOM.createOption(optionProductVariationTypeJson);
|
||||
console.log("optionProductVariationType: ", optionProductVariationType);
|
||||
ddlVariationType.appendChild(optionProductVariationType);
|
||||
});
|
||||
|
||||
let tdVariation = document.createElement("td");
|
||||
tdVariation.classList.add(flagProductVariation);
|
||||
DOM.setElementAttributesValuesCurrentAndPrevious(tdVariation, permutationVariationJson[attrIdProductVariation]);
|
||||
|
||||
let ddlVariation = document.createElement("select");
|
||||
ddlVariation.classList.add(flagProductVariation);
|
||||
DOM.setElementAttributesValuesCurrentAndPrevious(ddlVariation, permutationVariationJson[attrIdProductVariation]);
|
||||
|
||||
optionProductVariation = DOM.createOption(null);
|
||||
console.log("optionProductVariation: ", optionProductVariation);
|
||||
ddlVariation.appendChild(optionProductVariation);
|
||||
|
||||
productVariationKeys.forEach((productVariationKey) => {
|
||||
productVariation = productVariations[productVariationKey];
|
||||
optionProductVariationJson = BusinessObjects.getOptionJsonFromObjectJson(productVariation, permutationVariationJson[attrIdProductVariation]);
|
||||
optionProductVariation = DOM.createOption(optionProductVariationJson);
|
||||
console.log("optionProductVariation: ", optionProductVariation);
|
||||
ddlVariation.appendChild(optionProductVariation);
|
||||
});
|
||||
|
||||
let tdDelete = document.createElement("td");
|
||||
tdDelete.classList.add(flagDelete);
|
||||
|
||||
let buttonDelete = document.createElement("button");
|
||||
buttonDelete.classList.add(flagDelete);
|
||||
buttonDelete.textContent = 'x';
|
||||
|
||||
let tr = document.createElement("tr");
|
||||
tdVariationType.appendChild(ddlVariationType);
|
||||
tr.appendChild(tdVariationType);
|
||||
tdVariation.appendChild(ddlVariation);
|
||||
tr.appendChild(tdVariation);
|
||||
tdDelete.appendChild(buttonDelete);
|
||||
tr.appendChild(tdDelete);
|
||||
tbody.appendChild(tr);
|
||||
}
|
||||
handleClickButtonProductPermutationVariationsDelete(event, element) {
|
||||
let row = getRowFromElement(element);
|
||||
let variationsCell = row.closest('td.' + flagProductVariations);
|
||||
row.remove();
|
||||
this.updateProductPermutationVariations(variationsCell);
|
||||
}
|
||||
updateProductPermutationVariations(variationsCell) {
|
||||
let variationPairsString = this.getProductPermutationVariationsText(variationsCell);
|
||||
variationsCell.setAttribute(attrValueCurrent, variationPairsString);
|
||||
DOM.isElementDirty(variationsCell);
|
||||
}
|
||||
getProductPermutationVariationsText(variationsTd) {
|
||||
let rows = variationsTd.querySelectorAll('tr');
|
||||
let variationPairsString = '';
|
||||
let ddlVariationType, ddlVariation, idVariationType, idVariation;
|
||||
rows.forEach((row, index) => {
|
||||
ddlVariationType = row.querySelector('td select.' + flagProductVariationType);
|
||||
ddlVariation = row.querySelector('td select.' + flagProductVariation);
|
||||
idVariationType = ddlVariationType.getAttribute(attrValueCurrent);
|
||||
idVariation = ddlVariation.getAttribute(attrValueCurrent);
|
||||
variationPairsString += idVariationType + ':' + idVariation + ',';
|
||||
});
|
||||
return variationPairsString;
|
||||
}
|
||||
|
||||
handleClickPermutationsVariationsButtonAdd(element) {
|
||||
element = document.querySelectorAll(element);
|
||||
let row = getRowFromElement(element);
|
||||
let variations = row.querySelector('td.' + flagVariations + ' textarea');
|
||||
let value = variations.value;
|
||||
value = (Validation.isEmpty(value)) ? '' : value + '\n';
|
||||
value += 'Type: Variation\n';
|
||||
variations.value = value;
|
||||
handleChangeInputPermutations(variations);
|
||||
console.log("error: not implemented");
|
||||
hookupDescriptionTextareas() {
|
||||
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagDescription + ' textarea');
|
||||
}
|
||||
hookupCostFields(){
|
||||
this.hookupCurrencyCostFields();
|
||||
this.hookupCostInputs();
|
||||
}
|
||||
hookupCurrencyCostFields(){
|
||||
this.hookupTableCellDdlPreviews(idTableMain + ' td.' + flagCurrencyCost, Utils.getListFromDict(currencies));
|
||||
}
|
||||
hookupCostInputs(){
|
||||
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagCostLocal + ' input');
|
||||
}
|
||||
hookupProfitFields(){
|
||||
// this.hookupCurrencyProfitFields();
|
||||
this.hookupProfitInputs();
|
||||
}
|
||||
/*
|
||||
hookupCurrencyProfitFields(){
|
||||
this.hookupTableCellDdlPreviews(idTableMain + ' td.' + flagCurrency, Utils.getListFromDict(currencies));
|
||||
}
|
||||
*/
|
||||
hookupProfitInputs(){
|
||||
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagProfitLocalMin + ' input');
|
||||
}
|
||||
hookupLatencyManufactureInputs(){
|
||||
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagLatencyManufactureDays + ' input');
|
||||
}
|
||||
hookupQuantityFields(){
|
||||
this.hookupQuantityMinInputs();
|
||||
this.hookupQuantityMaxInputs();
|
||||
this.hookupQuantityStockInputs();
|
||||
this.hookupCountUnitMeasurementPerQuantityStepInputs();
|
||||
this.hookupUnitMeasurementQuantityFields();
|
||||
}
|
||||
hookupQuantityMinInputs() {
|
||||
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagQuantityMin + ' input');
|
||||
}
|
||||
hookupQuantityMaxInputs() {
|
||||
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagQuantityMax + ' input');
|
||||
}
|
||||
hookupQuantityStockInputs() {
|
||||
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagQuantityStock + ' input');
|
||||
}
|
||||
hookupCountUnitMeasurementPerQuantityStepInputs() {
|
||||
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagCountUnitMeasurementPerQuantityStep + ' input');
|
||||
}
|
||||
hookupUnitMeasurementQuantityFields() {
|
||||
console.log("hooking up unit measurement quantity fields");
|
||||
this.hookupTableCellDdlPreviews(idTableMain + ' td.' + flagUnitMeasurementQuantity, Utils.getListFromDict(unitMeasurements));
|
||||
}
|
||||
hookupSubscriptionFields() {
|
||||
this.hookupIsSubscriptionFields();
|
||||
this.hookupIntervalRecurrenceFields();
|
||||
this.hookupCountIntervalRecurrenceInputs();
|
||||
}
|
||||
hookupIsSubscriptionFields(){
|
||||
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagIsSubscription + ' input', (event, element) => {
|
||||
this.handleChangeElementCellTable(event, element);
|
||||
let isSubscription = DOM.getElementValueCurrent(element);
|
||||
let row = DOM.getRowFromElement(element);
|
||||
let inputCountIntervalRecurrence = row.querySelector('td.' + flagCountUnitMeasurementIntervalRecurrence + ' input');
|
||||
let divOrDdlIntervalRecurrence = row.querySelector('td.' + flagUnitMeasurementIntervalRecurrence + ' .' + flagUnitMeasurementIntervalRecurrence);
|
||||
if (isSubscription) {
|
||||
inputCountIntervalRecurrence.classList.remove(flagCollapsed);
|
||||
DOM.setElementValueCurrentIfEmpty(inputCountIntervalRecurrence, 1);
|
||||
divOrDdlIntervalRecurrence.classList.remove(flagCollapsed);
|
||||
let tdUnitMeasurementIntervalRecurrence = divOrDdlIntervalRecurrence.closest('td');
|
||||
tdUnitMeasurementIntervalRecurrence.dispatchEvent(new Event('click'));
|
||||
} else {
|
||||
inputCountIntervalRecurrence.classList.add(flagCollapsed);
|
||||
divOrDdlIntervalRecurrence.classList.add(flagCollapsed);
|
||||
}
|
||||
});
|
||||
}
|
||||
hookupIntervalRecurrenceFields(){
|
||||
this.hookupTableCellDDlPreviewsWhenNotCollapsed(idTableMain + ' td.' + flagUnitMeasurementIntervalRecurrence, Utils.getListFromDict(unitMeasurementsTime));
|
||||
}
|
||||
hookupCountIntervalRecurrenceInputs(){
|
||||
this.hookupChangeHandlerTableCellsWhenNotCollapsed("change", idTableMain + ' td.' + flagCountUnitMeasurementIntervalRecurrence + ' input');
|
||||
}
|
||||
hookupIdStripeProductInputs(){
|
||||
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagIdStripeProduct + ' input');
|
||||
}
|
||||
hookupExpirationFields(){
|
||||
this.hookupDoesExpireFasterOnceUnsealedCheckboxes();
|
||||
this.hookupIntervalExpirationUnsealedFields();
|
||||
this.hookupCountIntervalExpirationUnsealedInputs();
|
||||
}
|
||||
hookupDoesExpireFasterOnceUnsealedCheckboxes(){
|
||||
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagDoesExpireFasterOnceUnsealed + ' input', (event, element) => {
|
||||
this.handleChangeElementCellTable(event, element);
|
||||
let doesExpireFasterOnceUnsealed = DOM.getElementValueCurrent(element);
|
||||
let row = DOM.getRowFromElement(element);
|
||||
let inputCountIntervalExpirationUnsealed = row.querySelector('td.' + flagCountUnitMeasurementIntervalExpirationUnsealed + ' input');
|
||||
let divOrDdlIntervalExpirationUnsealed = row.querySelector('td.' + flagUnitMeasurementIntervalExpirationUnsealed + ' .' + flagUnitMeasurementIntervalExpirationUnsealed);
|
||||
if (doesExpireFasterOnceUnsealed) {
|
||||
inputCountIntervalExpirationUnsealed.classList.remove(flagCollapsed);
|
||||
DOM.setElementValueCurrentIfEmpty(inputCountIntervalExpirationUnsealed, 1);
|
||||
divOrDdlIntervalExpirationUnsealed.classList.remove(flagCollapsed);
|
||||
let tdUnitMeasurementIntervalExpirationUnsealed = divOrDdlIntervalExpirationUnsealed.closest('td');
|
||||
tdUnitMeasurementIntervalExpirationUnsealed.dispatchEvent(new Event('click'));
|
||||
} else {
|
||||
inputCountIntervalExpirationUnsealed.classList.add(flagCollapsed);
|
||||
divOrDdlIntervalExpirationUnsealed.classList.add(flagCollapsed);
|
||||
}
|
||||
});
|
||||
}
|
||||
hookupIntervalExpirationUnsealedFields(){
|
||||
this.hookupTableCellDDlPreviewsWhenNotCollapsed(idTableMain + ' td.' + flagUnitMeasurementIntervalExpirationUnsealed, Utils.getListFromDict(unitMeasurementsTime));
|
||||
}
|
||||
hookupCountIntervalExpirationUnsealedInputs(){
|
||||
this.hookupChangeHandlerTableCellsWhenNotCollapsed("change", idTableMain + ' td.' + flagCountUnitMeasurementIntervalExpirationUnsealed + ' input');
|
||||
}
|
||||
hookupActiveCheckboxes(){
|
||||
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagActive + ' input');
|
||||
}
|
||||
|
||||
leave() {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user