Fix: User login on production.

This commit is contained in:
2024-11-21 08:21:51 +00:00
parent c40cc5a854
commit b955cfd1df
4 changed files with 102 additions and 65 deletions

View File

@@ -6,33 +6,45 @@
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Stock_Item';
CREATE TABLE IF NOT EXISTS Shop_Stock_Item (
id_stock INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
id_permutation INT NOT NULL,
CONSTRAINT FK_Shop_Stock_Item_id_permutation
id_stock INT NOT NULL AUTO_INCREMENT PRIMARY KEY
, id_permutation INT NOT NULL
, CONSTRAINT FK_Shop_Stock_Item_id_permutation
FOREIGN KEY (id_permutation)
REFERENCES Shop_Product_Permutation(id_permutation),
date_purchased DATETIME NOT NULL,
date_received DATETIME NULL,
id_location_storage INT NOT NULL,
CONSTRAINT FK_Shop_Stock_Item_id_location_storage
REFERENCES partsltd_prod.Shop_Product_Permutation(id_permutation)
, id_supplier_purchase_order INT
, CONSTRAINT FK_Shop_Stock_Item_id_supplier_purchase_order
FOREIGN KEY (id_supplier_purchase_order)
REFERENCES partsltd_prod.Shop_Supplier_Purchase_Order(id_order)
, id_manufacturing_purchase_order INT
, CONSTRAINT FK_Shop_Stock_Item_id_manufacturing_purchase_order
FOREIGN KEY (id_manufacturing_purchase_order)
REFERENCES partsltd_prod.Shop_Manufacturing_Purchase_Order(id_order)
, id_customer_sales_order INT
, CONSTRAINT FK_Shop_Stock_Item_id_customer_sales_order
FOREIGN KEY (id_customer_sales_order)
REFERENCES partsltd_prod.Shop_Customer_Sales_Order(id_order)
, date_purchased DATETIME NOT NULL
, date_received DATETIME
, id_location_storage INT NOT NULL
, CONSTRAINT FK_Shop_Stock_Item_id_location_storage
FOREIGN KEY (id_location_storage)
REFERENCES Shop_Storage_Location(id_location),
id_currency_cost INT NOT NULL,
CONSTRAINT FK_Shop_Stock_Item_id_currency
REFERENCES partsltd_prod.Shop_Storage_Location(id_location)
, id_currency_cost INT NOT NULL
, CONSTRAINT FK_Shop_Stock_Item_id_currency
FOREIGN KEY (id_currency_cost)
REFERENCES Shop_Currency(id_currency),
cost_local_VAT_incl FLOAT NULL,
cost_local_VAT_excl FLOAT NULL,
is_sealed BIT NOT NULL DEFAULT 1,
date_unsealed DATETIME NULL,
date_expiration DATETIME NOT NULL,
is_consumed BIT NOT NULL DEFAULT 0,
date_consumed DATETIME NULL,
active BIT NOT NULL DEFAULT 1,
created_on DATETIME,
created_by INT,
id_change_set INT,
CONSTRAINT FK_Shop_Stock_Item_id_change_set
REFERENCES partsltd_prod.Shop_Currency(id_currency)
, cost_local_VAT_incl FLOAT
, cost_local_VAT_excl FLOAT
, is_sealed BIT NOT NULL DEFAULT 1
, date_unsealed DATETIME
, date_expiration DATETIME NOT NULL
, is_consumed BIT NOT NULL DEFAULT 0
, date_consumed DATETIME
, active BIT NOT NULL DEFAULT 1
, created_on DATETIME
, created_by INT
, id_change_set INT
, CONSTRAINT FK_Shop_Stock_Item_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES Shop_Product_Change_Set(id_change_set)
REFERENCES partsltd_prod.Shop_Product_Change_Set(id_change_set)
);

View File

@@ -95,6 +95,7 @@ BEGIN
id_link INT NOT NULL PRIMARY KEY
, id_order INT NOT NULL
, id_permutation INT NOT NULL
, id_product INT
-- , id_currency_cost INT NOT NULL
, quantity_ordered FLOAT NOT NULL
, id_unit_quantity INT NOT NULL
@@ -109,6 +110,7 @@ BEGIN
, has_order BIT NULL
, is_new BIT NOT NULL
, name_error VARCHAR(1000) NULL
, can_edit BIT
);
CREATE TEMPORARY TABLE IF NOT EXISTS tmp_Msg_Error (
@@ -191,9 +193,11 @@ BEGIN
, RANK() OVER (PARTITION BY IFNULL(IFNULL(SPOPL_T.id_order, SPOPL.id_order), 0) ORDER BY IFNULL(IFNULL(SPOPL_T.display_order, SPOPL.display_order), 0)) AS display_order
, IFNULL(IFNULL(SPOPL_T.cost_total_local_VAT_excl, SPOPL.cost_total_local_VAT_excl), 0) AS cost_total_local_VAT_excl
, IFNULL(IFNULL(SPOPL_T.cost_total_local_VAT_incl, SPOPL.cost_total_local_VAT_incl), 0) AS cost_total_local_VAT_incl
, IFNULL(SPOPL_T.cost_total_local_VAT_excl / SPOPL_T.quantity_ordered, SPOPL.cost_unit_local_VAT_excl) AS cost_unit_local_VAT_excl
/*
, IFNULL(SPOPL_T.cost_total_local_VAT_excl / SPOPL_T.quantity_ordered, SPOPL.cost_unit_local_VAT_excl) AS cost_unit_local_VAT_excl
, IFNULL(SPOPL_T.cost_total_local_VAT_incl / SPOPL_T.quantity_ordered, SPOPL.cost_unit_local_VAT_incl) AS cost_unit_local_VAT_incl
, IFNULL(IFNULL(SPOPL_T.active, SPOPL.active), 1) AS active
*/
, IFNULL(IFNULL(SPOPL_T.active, SPOPL.active), 1) AS active
, NOT ISNULL(t_SPO.id_order) AS has_order
, IFNULL(SPOPL_T.id_link, 0) < 1 AS is_new
FROM partsltd_prod.Shop_Supplier_Purchase_Order_Product_Link_Temp SPOPL_T
@@ -203,13 +207,18 @@ BEGIN
;
UPDATE tmp_Supplier_Purchase_Order_Product_Link t_SPOPL
INNER JOIN partsltd_prod.Shop_Supplier_Purchase_Order_Product_Link_Temp SPOPL_T ON t_SPOPL.id_order = SPOPL_T.id_order
LEFT JOIN partsltd_prod.Shop_Supplier_Purchase_Order_Product_Link_Temp SPOPL_T
ON t_SPOPL.id_link = SPOPL_T.id_link
AND t_SPOPL.GUID = a_guid
LEFT JOIN partsltd_prod.Shop_Supplier_Purchase_Order_Product_Link SPOPL ON t_SPOPL.id_link = SPOPL.id_link
LEFT JOIN partsltd_prod.Shop_Product_Permutation PP ON t_SPOPL.id_permutation = PP.id_permutation
LEFT JOIN partsltd_prod.Shop_Product P ON SPOPL_T.id_product = P.id_product
LEFT JOIN partsltd_prod.Shop_Product_Category PC ON P.id_category = PC.id_category
SET
name_error = CONCAT(
t_SPOPL.id_product = IFNULL(P.id_product, SPOPL_T.id_product)
, t_SPOPL.name_error = CONCAT(
CASE WHEN ISNULL(t_SPOPL.id_permutation) THEN
CASE WHEN ISNULL(SPOPL_T.id_product) THEN
CASE WHEN ISNULL(P.id_product) THEN
'(No Product Permutation)'
ELSE
CONCAT(
@@ -224,6 +233,10 @@ BEGIN
, ' - x'
, IFNULL(t_SPOPL.quantity_ordered, '(No Quantity)')
)
, t_SPOPL.cost_unit_local_VAT_excl = t_SPOPL.cost_total_local_VAT_excl / t_SPOPL.quantity_ordered
, t_SPOPL.cost_unit_local_VAT_incl = t_SPOPL.cost_total_local_VAT_incl / t_SPOPL.quantity_ordered
, t_SPOPL.delta_quantity_ordered = t_SPOPL.quantity_ordered - IFNULL(SPOPL.quantity_ordered, 0)
, t_SPOPL.delta_quantity_received = t_SPOPL.quantity_received - IFNULL(SPOPL.quantity_received, 0)
;
INSERT INTO tmp_Supplier_Purchase_Order (
@@ -558,8 +571,37 @@ BEGIN
IF a_debug = 1 THEN
SELECT * from partsltd_prod.Shop_Calc_User_Temp WHERE GUID = a_guid;
END IF;
UPDATE tmp_Supplier_Purchase_Order_Product_Link t_SPOPL
INNER JOIN partsltd_prod.Shop_Calc_User_Temp CUT
ON t_SPOPL.id_product = t_SPOPL.id_product
AND CUT.GUID = a_guid
SET
t_SPOPL.can_edit = CUT.can_edit
;
IF EXISTS (SELECT * FROM partsltd_prod.Shop_Calc_User_Temp UE_T WHERE UE_T.GUID = a_guid AND IFNULL(UE_T.can_view, 0) = 0) THEN
IF EXISTS (SELECT * FROM tmp_Supplier_Purchase_Order_Product_Link WHERE can_edit = 0) THEN
INSERT INTO tmp_Msg_Error (
id_type
, code
, msg
)
SELECT
v_id_type_error_no_permission
, v_code_type_error_no_permission
, CONCAT(
'You do not permissions to edit the following Product(s): '
, GROUP_CONCAT(P.name SEPARATOR ', ')
) AS msg
FROM tmp_Supplier_Purchase_Order_Product_Link t_SPOPL
INNER JOIN partsltd_prod.Shop_Product P ON t_SPOPL.id_product = P.id_product
WHERE
t_SPOPL.is_new = 0
AND t_SPOPL.can_view = 0
;
END IF;
IF EXISTS (SELECT * FROM tmp_Supplier_Purchase_Order_Product_Link WHERE is_new = 0 AND can_edit = 0 LIMIT 1) THEN
DELETE FROM tmp_Msg_Error;
INSERT INTO tmp_Msg_Error (
@@ -571,14 +613,16 @@ BEGIN
v_id_type_error_no_permission
, v_code_type_error_no_permission
, CONCAT(
'You do not have view permissions for '
, GROUP_CONCAT(name SEPARATOR ', ')
'You are missing the following permissions with access level '
, AL.name
, ': '
, GROUP_CONCAT(PERM.name SEPARATOR ', ')
) AS msg
FROM partsltd_prod.Shop_Permission PERM
INNER JOIN partsltd_prod.Shop_Calc_User_Temp UE_T
ON PERM.id_permission = UE_T.id_permission
AND UE_T.GUID = a_guid
AND IFNULL(UE_T.can_view, 0) = 0
FROM partsltd_prod.Shop_Access_Level AL
CROSS JOIN partsltd_prod.Shop_Calc_User_Temp CU_T
ON CU_T.GUID = a_guid
AND ISNULL(CU_T.id_product)
AND IFNULL(CU_T.can_edit, 0) = 0
;
END IF;

View File

@@ -1094,17 +1094,11 @@ var BasePage = /*#__PURE__*/function () {
var _this2 = this;
this.hookupEventHandler("click", '.' + flagNavUserLogin, function (event, navigator) {
event.stopPropagation();
// this.router.navigateToHash(hashPageUserLogin);
/*
let dataRequest = {};
dataRequest[flagCallback] = hashPageCurrent;
console.log('sending data to user login controller: ');
console.log(dataRequest);
*/
// let page = this;
_this2.leave();
api_API.loginUser().then(function (response) {
if (response.Success) {
_this2.router.navigateToUrl(response[flagCallback], null, false); // window.app.
// this.router.navigateToUrl(response[flagCallback], null, false); // window.app.
window.location.href = response[flagCallback];
} else {
DOM.alertError("Error", response.Message);
}
@@ -2642,18 +2636,15 @@ var TableBasePage = /*#__PURE__*/function (_BasePage) {
var changeHandler = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : function (event, element) {
_this14.handleChangeNestedElementCellTable(event, element);
};
debugger;
var row = DOM.getRowFromElement(element);
// row.classList.add(flagDelete);
if (row.classList.contains(flagRowNew) && !DOM.hasDirtyChildrenContainer(row)) {
row.parentNode.removeChild(row);
}
var buttonAdd = element.cloneNode(false); // document.createElement("button");
var buttonAdd = element.cloneNode(false);
buttonAdd.classList.remove(flagInitialised);
buttonAdd.classList.remove(flagDelete);
buttonAdd.classList.add(flagAdd);
buttonAdd.textContent = '+';
// DOM.setElementAttributeValueCurrent(buttonAdd, false);
element.replaceWith(buttonAdd);
changeHandler(null, buttonAdd);
this.hookupButtonsRowUndelete(selectorButtonDelete, selectorButtonUndelete, function (changeEvent, changeElement) {
@@ -2681,15 +2672,11 @@ var TableBasePage = /*#__PURE__*/function (_BasePage) {
var changeHandler = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : function (event, element) {
_this16.handleChangeNestedElementCellTable(event, element);
};
debugger;
// let row = DOM.getRowFromElement(element);
// row.classList.remove(flagDelete);
var buttonDelete = element.cloneNode(false); // document.createElement("button");
var buttonDelete = element.cloneNode(false);
buttonDelete.classList.remove(flagInitialised);
buttonDelete.classList.remove(flagAdd);
buttonDelete.classList.add(flagDelete);
buttonDelete.textContent = 'x';
// DOM.setElementAttributeValueCurrent(buttonDelete, true);
element.replaceWith(buttonDelete);
changeHandler(null, buttonDelete);
this.hookupButtonsRowDelete(selectorButtonDelete, selectorButtonUndelete, function (changeEvent, changeElement) {

View File

@@ -114,18 +114,12 @@ export default class BasePage {
hookupButtonsNavUserLogin() {
this.hookupEventHandler("click", '.' + flagNavUserLogin, (event, navigator) => {
event.stopPropagation();
// this.router.navigateToHash(hashPageUserLogin);
/*
let dataRequest = {};
dataRequest[flagCallback] = hashPageCurrent;
console.log('sending data to user login controller: ');
console.log(dataRequest);
*/
// let page = this;
this.leave();
API.loginUser()
.then((response) => {
if (response.Success) {
this.router.navigateToUrl(response[flagCallback], null, false); // window.app.
// this.router.navigateToUrl(response[flagCallback], null, false); // window.app.
window.location.href = response[flagCallback];
} else {
DOM.alertError("Error", response.Message);
}