From 6ad86825eac89f9d9232a9eb7ce907130eb3530a Mon Sep 17 00:00:00 2001 From: teddy Date: Sun, 4 Aug 2024 02:58:55 +0100 Subject: [PATCH] 1. Contact us page fixed - Model_View_Contact had not been updated to match new arguments for Model_View_Base.\n 2. Logo border radius increased to hide pencil icon watermark in bottom right hand corner. \n 3. Nav layout structure now dynamic based on user permissions --- __pycache__/app.cpython-312.pyc | Bin 19991 -> 22706 bytes __pycache__/config.cpython-312.pyc | Bin 2512 -> 2579 bytes __pycache__/forms.cpython-312.pyc | Bin 6040 -> 6347 bytes app.py | 62 +- .../__pycache__/user.cpython-312.pyc | Bin 0 -> 9223 bytes business_objects/user.py | 209 +++ config.py | 1 + .../datastore_store.cpython-312.pyc | Bin 32715 -> 34526 bytes datastores/datastore_store.py | 85 +- forms.py | 7 +- .../argument_validation.cpython-312.pyc | Bin 34710 -> 34723 bytes lib/argument_validation.py | 1 + .../model_view_base.cpython-312.pyc | Bin 7087 -> 9108 bytes .../model_view_contact.cpython-312.pyc | Bin 1845 -> 1587 bytes models/model_view_base.py | 40 +- models/model_view_contact.py | 26 +- requirements.txt | 1 + static/MySQL/0000_combine.sql | 1396 ++++++++++------- .../1000_tbl_Shop_Product_Change_Set.sql | 2 +- .../MySQL/1001_tbl_Shop_User_Change_Set.sql | 2 +- ...l_Shop_Sales_And_Purchasing_Change_Set.sql | 2 +- static/MySQL/1003_tbl_Shop_Access_Level.sql | 2 +- static/MySQL/1010_tbl_File_Type.sql | 4 +- static/MySQL/1011_tbl_File_Type_Audit.sql | 4 +- static/MySQL/1012_tbl_Shop_General.sql | 2 +- static/MySQL/1014_tbl_Shop_Image_Type.sql | 2 +- static/MySQL/1100_tbl_Shop_Region.sql | 2 +- static/MySQL/1102_tbl_Shop_Region_Temp.sql | 2 +- static/MySQL/1103_tbl_Shop_Region_Branch.sql | 2 +- static/MySQL/1106_tbl_Shop_Plant.sql | 2 +- .../MySQL/1109_tbl_Shop_Storage_Location.sql | 2 +- .../1112_tbl_Shop_Storage_Location_Branch.sql | 2 +- static/MySQL/1115_tbl_Shop_Currency.sql | 2 +- .../MySQL/1118_tbl_Shop_Tax_Or_Surcharge.sql | 2 +- .../MySQL/1121_tbl_Shop_Unit_Measurement.sql | 2 +- ...4_tbl_Shop_Unit_Measurement_Conversion.sql | 2 +- static/MySQL/1200_tbl_Shop_Category.sql | 2 +- static/MySQL/1203_tbl_Shop_Product.sql | 2 +- .../1206_tbl_Shop_Product_Permutation.sql | 2 +- ...1208_tbl_Shop_Product_Permutation_Temp.sql | 4 +- static/MySQL/1209_tbl_Shop_Variation_Type.sql | 2 +- static/MySQL/1212_tbl_Shop_Variation.sql | 2 +- ...hop_Product_Permutation_Variation_Link.sql | 2 +- static/MySQL/1218_tbl_Shop_Stock_Item.sql | 12 +- .../MySQL/1220_tbl_Shop_Stock_Item_Temp.sql | 8 +- static/MySQL/1221_tbl_Shop_Product_Price.sql | 2 +- static/MySQL/1224_tbl_Shop_Product_Image.sql | 2 +- .../MySQL/1227_tbl_Shop_Delivery_Option.sql | 2 +- ..._tbl_Shop_Product_Delivery_Option_Link.sql | 2 +- static/MySQL/1233_tbl_Shop_Discount.sql | 6 +- ...tbl_Shop_Discount_Region_Currency_Link.sql | 2 +- ..._tbl_Shop_Product_Currency_Region_Link.sql | 2 +- .../MySQL/1300_tbl_Shop_Permission_Group.sql | 2 +- static/MySQL/1303_tbl_Shop_Permission.sql | 2 +- static/MySQL/1306_tbl_Shop_Role.sql | 2 +- .../1309_tbl_Shop_Role_Permission_Link.sql | 2 +- static/MySQL/1312_tbl_Shop_User.sql | 13 +- static/MySQL/1313_tbl_Shop_User_Audit.sql | 2 +- static/MySQL/1315_tbl_Shop_User_Role_Link.sql | 4 +- static/MySQL/1318_tbl_Shop_Address.sql | 4 +- static/MySQL/1321_tbl_Shop_User_Basket.sql | 4 +- static/MySQL/1397_tbl_Shop_Order_Status.sql | 2 +- static/MySQL/1400_tbl_Shop_Supplier.sql | 2 +- .../1409_tbl_Shop_Supplier_Purchase_Order.sql | 4 +- ...p_Supplier_Purchase_Order_Product_Link.sql | 4 +- ...plier_Purchase_Order_Product_Link_Temp.sql | 2 +- ..._tbl_Shop_Manufacturing_Purchase_Order.sql | 4 +- ...ufacturing_Purchase_Order_Product_Link.sql | 4 +- ...uring_Purchase_Order_Product_Link_Temp.sql | 2 +- static/MySQL/1421_tbl_Shop_Customer.sql | 2 +- .../1424_tbl_Shop_Customer_Sales_Order.sql | 4 +- ...Shop_Customer_Sales_Order_Product_Link.sql | 4 +- ...Customer_Sales_Order_Product_Link_Temp.sql | 2 +- static/MySQL/3312_tri_Shop_User.sql | 34 +- static/MySQL/6000_p_split.sql | 21 +- static/MySQL/6500_p_shop_user_eval.sql | 113 +- static/MySQL/7203_p_shop_save_product.sql | 23 +- static/MySQL/7204_p_shop_get_many_product.sql | 8 +- ...205_p_shop_get_many_stripe_product_new.sql | 8 +- static/MySQL/7206_p_shop_save_permutation.sql | 6 +- .../MySQL/7219_p_shop_get_many_stock_item.sql | 26 +- .../7223_p_shop_get_many_stripe_price_new.sql | 8 +- static/MySQL/7312_p_shop_save_user.sql | 6 +- static/MySQL/7313_p_get_many_user.sql | 231 +++ static/MySQL/7321_p_shop_save_user_basket.sql | 10 +- static/MySQL/7400_p_shop_save_supplier.sql | 6 +- .../MySQL/7401_p_shop_get_many_supplier.sql | 10 +- .../7403_p_save_supplier_purchase_order.sql | 6 +- ..._shop_get_many_supplier_purchase_order.sql | 12 +- ...shop_save_manufacturing_purchase_order.sql | 6 +- ..._get_many_manufacturing_purchase_order.sql | 12 +- static/MySQL/7421_p_shop_save_customer.sql | 6 +- .../MySQL/7422_p_shop_get_many_customer.sql | 8 +- .../7424_p_shop_save_customer_sales_order.sql | 6 +- ...5_p_shop_get_many_customer_sales_order.sql | 12 +- static/MySQL/9000_populate.sql | 26 +- static/MySQL/9010_anal.sql | 3 +- .../000_init_tables_authentication.sql | 18 +- .../deprecated/000_init_tables_product.sql | 38 +- .../108_tbl_Shop_Recurrence_Interval.sql | 2 +- ...1_tbl_Shop_Product_Variation_Type_Link.sql | 2 +- .../116_tbl_Shop_Product_Variation_Link.sql | 2 +- ..._tbl_Shop_Product_Delivery_Region_Link.sql | 2 +- .../deprecated/170_ish_tbl_ERP_Order.sql | 2 +- .../deprecated/171_tbl_Shop_User_Order.sql | 4 +- .../173_tbl_Shop_User_Order_Product_Link.sql | 2 +- .../7000_p_shop_get_many_role_permission.sql | 2 +- .../7000_p_shop_get_many_user_order.sql | 8 +- .../deprecated/706_p_shop_get_product.sql | 8 +- static/MySQL/deprecated/dump.sql | 62 +- static/MySQL/deprecated/dump2.sql | 62 +- static/MySQL/temp.txt | 2 + templates/_page_accessibility_statement.html | 6 +- templates/_page_contact.html | 30 +- templates/_page_privacy_notice.html | 2 +- templates/layout.html | 63 +- 116 files changed, 1878 insertions(+), 1039 deletions(-) create mode 100644 business_objects/__pycache__/user.cpython-312.pyc create mode 100644 business_objects/user.py create mode 100644 static/MySQL/7313_p_get_many_user.sql diff --git a/__pycache__/app.cpython-312.pyc b/__pycache__/app.cpython-312.pyc index 91f49b590b40da545de4d5cb45ad6a66069a1bf8..6175afc8b987ce4d1dbd0fe9b4b9dc754a3b61e7 100644 GIT binary patch delta 6010 zcmaJ_4Nx3McAlQu|6P6rEFc8ZA}qv82oScg1PF=WMMgr7!1hU&Jz91~uxQy`^$xNi z;6;iONoSu$uANAUea@ZZbE2~9&Uc%f?K@XwozJ;T*-n;%E4V4*=o}}h)Fl@vsmdu; zs*?9+c44$KnOfew?tWkQ>-WC?8Lqxce)t1Y^>J2~gM%mf`u9$Tx;gHjv5)%aKTA3bc=05A)48>1P;MShu8x-0STxHWCvwwQwGIC=ZMFKAPo?Ma7O&S5 z4*dSrszq9pYSWfd-34yN@sS6u;|P&tx8YDLw(#}Ya z8nDqdFuOA_{yhfJ=`}%(_YKr!z|b`?&C)KZage{!z&?N|$JVfF$#7?%p=V_c%>E2a zs{u3m)tI={2F@5`)ouWtkvbsC&wVvi>dZiP8IWh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ydHx&*wqC#KBNT4?fSwBKp-6KCEH$fjXw_uOJ`IecQ<{kd?h z#c;8^)cG#5=HQ*~K6V7M_x!POEi%&58^Yq{jf_U3cmc^=ol5W|zlKwfiL~84)fgq& zb8GFCvED-GbzJbISnx(KE%>DO_jUg-Z4Tb1GvTpWIi5)3R{8t5{sOMwS9}Dmv`3cl z(-4>C;F+{rmX*YqEc5o%o_$vsdj-Dg19l3Y>Mvq@;I;lC)&~FTS0FOb#D-yEpq@>^ zp9ZSuyD*UWpz}ep=mRP~Zd@a4nt-lTao>siLVp|S?GXLUsdL0>i=)$zf}|DdaN4mb zJ8kFFam#-cw>>TEV+mzCsivIDi$Hp4Jln`!f)W9G6cF0Zk L&zhV^Z0`R827@0z diff --git a/__pycache__/config.cpython-312.pyc b/__pycache__/config.cpython-312.pyc index 043c8ef11717c649fd75b8db1be74d78ac4baad7..7d0f1bb437a420bcf5db9dc52589b317ea16530e 100644 GIT binary patch delta 328 zcmca0JXwVIG%qg~0}$M6Se15bBku%8#=On*7`>S$2Qo|Yi>zh@$uTfQ$yADJifw+& zEX~M!iz771C*H$9IK)p=b~86CGb3w}2vE&rKDGiz=gswOCX6Bt?l<@)I*R%$J1b{M zUFKJ5^e9rByq(?0Srn+SNDM@Xg9v31p$a0@K!iGo(1Z~VKt?e;kZ57J!6VS<3Q?mu zc@MkfpB9uUc3W!hz5o#bp14h^b8O7{CqJ`lG zk3gdqOftit!@gox#Bg-hcX1IFxN)}DlTY_%+MY-{AnK>n? zMaA)<#i>PAJdVjFnPsU8`FS~&_Eqd4F$GVTq5_~XewrMU9r?uS6TvFtK`M$kf#OB{ zK;jmAW=ec1P<4?aNJt4pD1(T47|{o06w3jL7KWQbax>~K3+Xj@-{g~=p}A3Fv(yHj z14&o-JR991T0y$}H05ux$H%ASC&$O%;!Mj)EY6NEFG-usFSdcPe)4WHS*~`VDn^j8 ednP{;TO;v>ft6AFix3l|7vl`huM8j>Y#IO!m{}YE delta 75 zcmX?YI76TJG%qg~0}$91E=#kT$ScVhvQa&hk)={bQ+D$-#tIQ;KTWyG(&9%ZKM|MY bY6dD~1mfa#li4NKaD8Q9Wz;TG0tx^C;6xHV diff --git a/app.py b/app.py index 3dbc6b43..bd7668ec 100644 --- a/app.py +++ b/app.py @@ -72,6 +72,7 @@ app.ID_AUTH0_CLIENT = Config.ID_AUTH0_CLIENT app.ID_AUTH0_CLIENT_SECRET = Config.ID_AUTH0_CLIENT_SECRET app.DOMAIN_AUTH0 = Config.DOMAIN_AUTH0 app.ID_TOKEN_USER = Config.ID_TOKEN_USER +app.URL_HOST = Config.URL_HOST app.config.SQLALCHEMY_DATABASE_URI = Config.SQLALCHEMY_DATABASE_URI app.config.SQLALCHEMY_TRACK_MODIFICATIONS = Config.SQLALCHEMY_TRACK_MODIFICATIONS @@ -79,7 +80,7 @@ app.config.ID_AUTH0_CLIENT = Config.ID_AUTH0_CLIENT app.config.ID_AUTH0_CLIENT_SECRET = Config.ID_AUTH0_CLIENT_SECRET app.config.DOMAIN_AUTH0 = Config.DOMAIN_AUTH0 app.config.ID_TOKEN_USER = Config.ID_TOKEN_USER - +app.config.URL_HOST = Config.URL_HOST app.config['SQLALCHEMY_DATABASE_URI'] = Config.SQLALCHEMY_DATABASE_URI app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = Config.SQLALCHEMY_TRACK_MODIFICATIONS app.config['ID_AUTH0_CLIENT'] = Config.ID_AUTH0_CLIENT @@ -123,7 +124,6 @@ app.config['RECAPTCHA_PRIVATE_KEY'] = Config.RECAPTCHA_PRIVATE_KEY # db = SQLAlchemy(app) app.config['SQLALCHEMY_DATABASE_URI'] = Config.SQLALCHEMY_DATABASE_URI -""" oauth = OAuth(app) oauth.register( "auth0", @@ -131,11 +131,11 @@ oauth.register( client_secret = app.ID_AUTH0_CLIENT_SECRET, # =env.get("AUTH0_CLIENT_SECRET"), client_kwargs={ "scope": "openid profile email", - }, - server_metadata_url=f'https://{app.DOMAIN_AUTH0}/.well-known/openid-configuration' + } + # server_metadata_url=f'https://{app.DOMAIN_AUTH0}/.well-known/openid-configuration' ) # session[app.ID_TOKEN_USER] = {'userinfo': {'sub': ''}} -""" + db = SQLAlchemy() db.init_app(app) @@ -176,6 +176,7 @@ def application(environ, start_response): def home(): try: model = Model_View_Home(app, db) + print('nips') html_body = render_template('_page_home.html', model = model) except Exception as e: return str(e) @@ -366,6 +367,57 @@ def stock_save(): return jsonify({'status': 'failure', 'Message': f'Bad data received by controller.\n{e}'}) """ + +# User authentication +@app.route("/login") +def login(): + try: + data = request.json + except: + data = {} + callback_login = F'{Model_View_Base.HASH_CALLBACK_LOGIN}/{data.get(Model_View_Base.KEY_CALLBACK, Model_View_Base.HASH_PAGE_HOME)}' + uri_redirect = url_for(callback_login, _external=True) + print(f'redirect uri: {uri_redirect}') + return oauth.auth0.authorize_redirect( + redirect_uri = uri_redirect + ) + +@app.route("/login_callback/") +def login_callback(subpath): + token = oauth.auth0.authorize_access_token() + session[app.ID_TOKEN_USER] = token + + # import user id + print(f'str(type(token)) = {str(type(token))}') + print(f'token = {token}') + userinfo = token.get('userinfo') + print(f'user info: {userinfo}') + # id_user = token.get('sub') + id_user = userinfo.get('sub') + print(f'user ID: {id_user}') + + # id_user = get_id_user() + # add user to database + # DataStore_Store(db, userinfo).add_new_user(id_user) # this is part of get basket - should occur on page load + + return redirect(subpath) + +@app.route("/logout") +def logout(): + session.clear() + return redirect( + "https://" + app.DOMAIN_AUTH0 + + "/v2/logout?" + + urlencode( + { + "returnTo": url_for("home", _external=True), + "client_id": app.ID_AUTH0_CLIENT, + }, + quote_via=quote_plus, + ) + ) + + # snore @app.route('/license', methods=['GET']) def license(): diff --git a/business_objects/__pycache__/user.cpython-312.pyc b/business_objects/__pycache__/user.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6383e588bb6fe9e9b1c8bcc81b84a99f8a558816 GIT binary patch literal 9223 zcmeG?TTC2Tc2(Wg?UWm zWJ^dp8)0Q78|?>>$qM+gkw-h;k4TPI+GM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_W;`=rT~QuuX8ZTH3d`FW(r4a?h^%<669TJ$`O2elCAt1SHP0VK|cE`T9{7ie2W? zj!c+uE9}Lrled_48jaWQJS(2U**T417y+H$Gl=au$7hkd=S1g_ix>T!M@)42)bBq5 zMA-oF31dorJQE&`6hc3M1c=A?@c4t{kFL<%h4QnH3ZDHl!`pcl$kY`4oseT`+qZOm z@%l1(JiRhqXdB3L&04Jc@%5GKPsr!ftJ8(pV4myHYU<{j=9(4;mIfCG3pHIc=S{5| zDVO%n$4x6uPX<08TpcX5zm?}ATA=3P)Pt#o+NI{j=0afq%(*I*azdzQv8ND>&5V4- z`D{I}B0igu<)h<`cj*qE7qThHn}ucRMqiRl(Dx@i#0LrP4*0sgt_qRh1zWd*3PGo; z+wfAT7?-`qoo`e6N^uWQ)dW)x1aH%N^De==rT6&+QxJN?E&+J02njqFGNZeg@Y3FR z@1Ldb{RtjC^`_lo#cu(K2l*|#_;6ilR>@guBOsiZ9G z!EyKs;5M(^k(0(}0wjoRPx(s$Q6V){0X}%ZbR)iWAh@%2+l4Ij*hu~11%$51j;;BP z^MsMue3#6E2p;T}zXY&lWm)#6#ldoa3^8nMgK6GiI{(0&TVu{`F#Q|Mfeq%w2Gh5} z4E!ro{|Dy4?-}0))4jp8Z!j${?TkJ6cS3!-p=O|FCqi lkOTn$Hz$i{ixx-O11$ITH8#!$munw4t~CA;lDx)7`Y)Qo>}LP~ literal 0 HcmV?d00001 diff --git a/business_objects/user.py b/business_objects/user.py new file mode 100644 index 00000000..a26b421e --- /dev/null +++ b/business_objects/user.py @@ -0,0 +1,209 @@ +""" +Project: PARTS Website +Author: Edward Middleton-Smith + Precision And Research Technology Systems Limited + +Technology: Business Objects +Feature: User Business Object +""" + +# internal +import lib.argument_validation as av +from lib import data_types +from forms import Form_Filters_User +from business_objects.product import Product, Product_Permutation, Price +from business_objects.variation import Variation +from business_objects.image import Image +from business_objects.delivery_option import Delivery_Option +from business_objects.discount import Discount +from business_objects.stock_item import Stock_Item +# external +from enum import Enum +from datetime import datetime, timedelta +import locale +from flask_sqlalchemy import SQLAlchemy +from dataclasses import dataclass +from typing import ClassVar + + +db = SQLAlchemy() + + +class User(db.Model): + id_user = db.Column(db.Integer, primary_key=True) + id_user_auth0 = db.Column(db.String(255)) + firstname = db.Column(db.String(255)) + surname = db.Column(db.String(255)) + email = db.Column(db.String(255)) + is_email_verified = db.Column(db.Boolean) + is_super_user = db.Column(db.Boolean) + id_currency_default = db.Column(db.Integer) + id_region_default = db.Column(db.Integer) + is_included_VAT_default = db.Column(db.Boolean) + can_admin_store = db.Column(db.Boolean) + can_admin_user = db.Column(db.Boolean) + + is_user_logged_in: bool = False + + def make_from_DB_user(query_row): + user = User() + user.id_user = query_row[0] + user.id_user_auth0 = query_row[1] + user.firstname = query_row[2] + user.surname = query_row[3] + user.email = query_row[4] + user.is_email_verified = query_row[5] + user.is_super_user = query_row[6] + user.id_currency_default = query_row[7] + user.id_region_default = query_row[8] + user.is_included_VAT_default = query_row[9] + user.can_admin_store = query_row[10] + user.can_admin_user = query_row[11] + return user + + def __repr__(self): + return f''' + id_user: {self.id_user} + id_user_auth0: {self.id_user_auth0} + firstname: {self.firstname} + surname: {self.surname} + email: {self.email} + is_email_verified: {self.is_email_verified} + is_super_user: {self.is_super_user} + id_currency_default: {self.id_currency_default} + id_region_default: {self.id_region_default} + is_included_VAT_default: {self.is_included_VAT_default} + can_admin_store: {self.can_admin_store} + can_admin_user: {self.can_admin_user} + ''' + + @staticmethod + def get_default(): + user = User() + user.id_user = None + return user + +@dataclass +class User_Filters(): + get_all_user: bool + get_inactive_user: bool + get_first_user_only: bool + ids_user: str + ids_user_auth0: str + + def to_json(self): + return { + 'a_get_all_user': self.get_all_user, + 'a_get_inactive_user': self.get_inactive_user, + 'a_get_first_user_only': self.get_first_user_only, + 'a_ids_user': self.ids_user, + 'a_ids_user_auth0': self.ids_user_auth0, + } + + @staticmethod + def from_form(form): + av.val_instance(form, 'form', 'User_Filters.from_form', Form_Filters_User) + get_inactive = av.input_bool(form.active_only.data, "active_only", "User_Filters.from_form") + id_user = form.id_user.data + return User_Filters( + get_all_user = (id_user is None), + get_inactive_user = get_inactive, + get_first_user_only = False, + ids_user = id_user, + ids_user_auth0 = '', + ) + + @staticmethod + def get_default(datastore_store): + user = datastore_store.get_login_user() + return User_Filters( + get_all_user = False, + get_inactive_user = False, + get_first_user_only = False, + ids_user = user.id_user, + ids_user_auth0 = '', + ) +""" User_Eval +@dataclass +class User_Filters(): + ids_user: str + get_inactive_users: bool + ids_permission: str + ids_access_level: str + ids_product: str + + def to_json(self): + return { + 'a_ids_user': self.ids_user, + 'a_get_inactive_users': self.get_inactive_users, + 'a_ids_permission': self.ids_permission, + 'a_ids_access_level': self.ids_access_level, + 'a_ids_product': self.ids_product, + } + + @staticmethod + def from_form(form): + av.val_instance(form, 'form', 'User_Filters.from_form', Form_Filters_User) + get_inactive = av.input_bool(form.active_only.data, "active_only", "User_Filters.from_form") + return User_Filters( + ids_user = form.id_user.data, + get_inactive_users = get_inactive, + ids_permission = form.ids_permission.data, + ids_access_level = form.ids_access_level.data, + ids_product = form.ids_product.data, + ) + + @staticmethod + def get_default(datastore_store): + is_user_logged_in, id_user = datastore_store.get_login_user() + return User_Filters( + ids_user = id_user, + get_inactive_users = False, + ids_permission = '', + ids_access_level = '', + ids_product = '', + ) +""" + +class User_Permission_Evaluation(db.Model): + id_evaluation = db.Column(db.Integer, primary_key=True) + guid = db.Column(db.String(255)) + id_user = db.Column(db.Integer) + id_permission_required = db.Column(db.Integer) + priority_access_level_required = db.Column(db.Integer) + id_product = db.Column(db.Integer) + is_super_user = db.Column(db.Boolean) + priority_access_level_user = db.Column(db.Integer) + can_view = db.Column(db.Boolean) + can_edit = db.Column(db.Boolean) + can_admin = db.Column(db.Boolean) + + def make_from_DB_user_eval(query_row): + user_permission_evaluation = User_Permission_Evaluation() + user_permission_evaluation.id_evaluation = query_row[0] + user_permission_evaluation.guid = query_row[1] + user_permission_evaluation.id_user = query_row[2] + user_permission_evaluation.id_permission_required = query_row[3] + user_permission_evaluation.priority_access_level_required = query_row[4] + user_permission_evaluation.id_product = query_row[5] + user_permission_evaluation.is_super_user = query_row[6] + user_permission_evaluation.priority_access_level_user = query_row[7] + user_permission_evaluation.can_view = query_row[8] + user_permission_evaluation.can_edit = query_row[9] + user_permission_evaluation.can_admin = query_row[10] + return user_permission_evaluation + + def __repr__(self): + return f''' + id_evaluation: {self.id_evaluation} + guid: {self.guid} + id_user: {self.id_user} + id_permission_required: {self.id_permission_required} + priority_access_level_required: {self.priority_access_level_required} + id_product: {self.id_product} + is_super_user: {self.is_super_user} + priority_access_level_user: {self.priority_access_level_user} + can_view: {self.can_view} + can_edit: {self.can_edit} + can_admin: {self.can_admin} + ''' diff --git a/config.py b/config.py index 65b900f8..76ba87d5 100644 --- a/config.py +++ b/config.py @@ -59,6 +59,7 @@ class Config: # Miscellaneous DEBUG = False TESTING = False + URL_HOST = os.getenv('URL_HOST') class DevelopmentConfig(Config): DEBUG = True diff --git a/datastores/__pycache__/datastore_store.cpython-312.pyc b/datastores/__pycache__/datastore_store.cpython-312.pyc index 77fca448a07551ede3f4ea5f6a7f3f9adf0f71e3..a5f1bd0366e49932af94a7e177dab1cbc63059ea 100644 GIT binary patch delta 5918 zcmbtY3vg7|dA{fF-n(z@F1xD-LhnUl1(Fa*#(o{?rp0*Z(O1<%v)a|tKwA0EY&BU}G_y5n; z3l%z<=^g3Y|NiGc=lth?opbJoUy{H7hFI{S!(kQR+4k|Py_eq{Ehr}YM(f@lNmd7| zlQqE_B1A~UneZo923K<0m8ebD1?xENPOM4>f&or1OVlS<2Ul}iOsom6fqr75A=m)F zoj;QR6B{ET}YRmasPn0HOsv1kDlpQBRiNR0?NER@h zC1=N9H!LHhn*GFh%oVA6N(k2Gg;OM0cTfn_jJHZZC2}oHMC(|g>2Kr!lB?LinpV$o zSD4RMGy^wV+!e}%4rbCcs&H&nlvpa3QIu}>zWI6U01NEQ2c zTfl6g_X2}%VHNfwr*RNXA=9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T7<+a2aC$r{4ehxB8%EF9nGafNMJ+i6VF>>&cXYF^lfD{bH&*+>Gp zzLD1mtI7*AP2(==XKVQVLbdD*#w5I1P~M(<*o11=a+nkuj)v(CIHFG^M|dNM*Nb#8 zou;%JkHDx??b8e^p%-UIN zLU=4={Z{M@c+$~;Wq1APYSScI`V;6J-BNbFYin8UM}pqk29J$aT1Vb-v|cge+lA3} z>|X)yyO&zAJr_x@SPMrd>+C$r%h(VdgmaUgaW9e;2pH?M1fdAQhfssCkb&xmC&O|~ z3MCT*(FkqC@$Cpl5FS9_*=;jY-3Yv&`v9r;5k5h{5=RZF0z1M2B5Y@c07=ZRv>t)| z8)Ui(?_`wflq4QOU4)W4=d3GyEsb8{vkP(RvPyOX*8H->6&8usumB*u@q~a8ns{6 zaY*rua#xIUhj9(CB(PUv@4;ATP>yG~##Gz90qhmEGPw-TGx8l=yQ(GClL-eC>1c>z zF4NR&N@r47;<#nd2RYZL1WkfgHZWyrXC@eq$?K`a6vO@mB?!sGtKjtE%KRZGDLx+k Kr+~kF&wl{be{=f) diff --git a/datastores/datastore_store.py b/datastores/datastore_store.py index d22d43e1..9bae46a3 100644 --- a/datastores/datastore_store.py +++ b/datastores/datastore_store.py @@ -29,6 +29,7 @@ from business_objects.order import Order from business_objects.product import Product, Product_Permutation, Price, Product_Filters # Permutation_Variation_Link from business_objects.sql_error import SQL_Error from business_objects.stock_item import Stock_Item, Stock_Item_Filters +from business_objects.user import User, User_Filters, User_Permission_Evaluation from business_objects.variation import Variation from helpers.helper_db_mysql import Helper_DB_MySQL # from models.model_view_store_checkout import Model_View_Store_Checkout # circular! @@ -115,8 +116,8 @@ class DataStore_Store(BaseModel): } """ argument_dict = product_filters.to_json() - is_user_logged_in, id_user = self.get_login_user() - argument_dict['a_id_user'] = 'auth0|6582b95c895d09a70ba10fef' # id_user + user = self.get_login_user() + argument_dict['a_id_user'] = 1 # 'auth0|6582b95c895d09a70ba10fef' # id_user print(f'argument_dict: {argument_dict}') print('executing p_shop_get_many_product') result = self.db_procedure_execute('p_shop_get_many_product', argument_dict) @@ -536,8 +537,8 @@ class DataStore_Store(BaseModel): _m = 'DataStore_Store.get_many_stock_item' av.val_instance(stock_item_filters, 'stock_item_filters', _m, Stock_Item_Filters) argument_dict = stock_item_filters.to_json() - is_user_logged_in, id_user = self.get_login_user() - argument_dict['a_id_user'] = 'auth0|6582b95c895d09a70ba10fef' # id_user + user = self.get_login_user() + argument_dict['a_id_user'] = 1 # 'auth0|6582b95c895d09a70ba10fef' # id_user print(f'argument_dict: {argument_dict}') print('executing p_shop_get_many_stock_item') result = self.db_procedure_execute('p_shop_get_many_stock_item', argument_dict) @@ -886,13 +887,14 @@ class DataStore_Store(BaseModel): return id_currency, id_region_delivery, is_included_VAT def get_login_user(self): + user = User.get_default() try: info_user = self.session[self.app.ID_TOKEN_USER].get('userinfo') - is_user_logged_in = ('sub' in list(info_user.keys()) and not info_user['sub'] == '' and not str(type(info_user['sub'])) == " 0: + errors = [SQL_Error.make_from_DB_record(row) for row in result_set_e] # [SQL_Error(row[0], row[1]) for row in result_set_e] + for error in errors: + print(f"Error [{error.code}]: {error.msg}") + + DataStore_Store.db_cursor_clear(cursor) + + return users, errors \ No newline at end of file diff --git a/forms.py b/forms.py index c9262416..372bb9c0 100644 --- a/forms.py +++ b/forms.py @@ -136,4 +136,9 @@ class Form_Filters_Stock_Item(FlaskForm): is_out_of_stock = BooleanField('Out of stock only?') quantity_min = FloatField('Min stock') quantity_max = FloatField('Max stock') - # submit = SubmitField('Submit') \ No newline at end of file + # submit = SubmitField('Submit') + + +class Form_Filters_User(FlaskForm): + active_only = BooleanField('Active only?') + id_user = SelectField('User ID', validators=[Optional()], choices=[]) \ No newline at end of file diff --git a/lib/__pycache__/argument_validation.cpython-312.pyc b/lib/__pycache__/argument_validation.cpython-312.pyc index 46b45590106d7c95d76445ad36f9cacf4955f6e1..88f50fb47d25a9f942af53f5765f370ddb78ed37 100644 GIT binary patch delta 400 zcmbQ%&$PIoiSINoFBbz4EW5idP3Xf$zV#{!$CwxxrZc24*0R+wG%!{&l`w)7fItm% z3UdwHzW@Mc#tft7yQ^T@`Z?dJDGbjHd z##)Yah7^Ixt!n8&)o;~Y8JQ*Bhlb;gPpITen#o!2})LzON}Hq z+iIpWGk)H@RHucNk#Dn>(Nz{kuTAC^tc*FED{bzwFs|4f?%2x2cxLlm=krXA_cpI} zo5#$^zS+m?I~$uRGXq1h!sOkNb0_<|^KAYUc$l5BY4f&7J}$QNASwCD^?9>4r=*B- lF&b>H$`fa2oVa;XX%!da$<4eCEo`iojKZJG7Efzq1OUrNb7uem delta 379 zcmZ47&or%{iSINoFBbz41jtLIy?MWpZ@miB0j9|ZwDLt6O4vaXAW*}Y!dkGf+$@vVsfkVIQrBY? zm~5$T&C8Rm!N5?&lp+w!05qUcU3Btv^|j1ynp~3~c#2Mr*685g%E-Xb!03RcGK&22V!Ss0gZPH}8y zVm!V1mGgNf#=Dz$xy@r{XJckyDCTCIe86qa=HFhSY>XzG0|N^=7#lYqj^yKFI|q`M upWKr-Yja_WC>Nvt=Jq^scE$;t=a*J-F`n2g)zHGmYQZS{xn%L;Hbwv}|7ZjN diff --git a/lib/argument_validation.py b/lib/argument_validation.py index e656c388..de245f3b 100644 --- a/lib/argument_validation.py +++ b/lib/argument_validation.py @@ -449,6 +449,7 @@ def input_bool(v_input, v_name, method, suppress_errors = False, suppress_consol # optional bool suppress_console_outputs # ARGUMENT VALIDATION my_f = 'input_bool' + if v_input is None: return False # suppress_errors val_bool(suppress_errors, 'suppress_errors', my_f) # suppress_console_outputs diff --git a/models/__pycache__/model_view_base.cpython-312.pyc b/models/__pycache__/model_view_base.cpython-312.pyc index bd1c8aa3bc6165c98e2d2afd7c36815ec74d836d..68da407c602c05d6733e1b0e74a510d4562b636f 100644 GIT binary patch delta 3492 zcmchaTTmO<8Gz49D_Ni$cZr+LSP+oQ&83MGLP>t?uAS`qYQ^A>;HilW99W{|W)I-HiK^ z!|A6> zu!vU1D%u#ERz4!w#W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!0*`i!GZJRNbHtXXnyV~R(*BI^+`*g NEW.name) + # Changed id_user_auth0 + SELECT NEW.id_user, 'id_user_auth0', OLD.id_user_auth0, NEW.id_user_auth0, NEW.id_change_set + WHERE NOT (OLD.id_user_auth0 <=> NEW.id_user_auth0) + UNION + # Changed firstname + SELECT NEW.id_user, 'firstname', OLD.firstname, NEW.firstname, NEW.id_change_set + WHERE NOT (OLD.firstname <=> NEW.firstname) + UNION + # Changed surname + SELECT NEW.id_user, 'surname', OLD.surname, NEW.surname, NEW.id_change_set + WHERE NOT (OLD.surname <=> NEW.surname) + UNION + # Changed email + SELECT NEW.id_user, 'email', OLD.email, NEW.email, NEW.id_change_set + WHERE NOT (OLD.email <=> NEW.email) + UNION + # Changed is_email_verified + SELECT NEW.id_user, 'is_email_verified', CONVERT(CONVERT(OLD.is_email_verified, SIGNED), CHAR), CONVERT(CONVERT(NEW.is_email_verified, SIGNED), CHAR), NEW.id_change_set + WHERE NOT (OLD.is_email_verified <=> NEW.is_email_verified) UNION # Changed is_super_user SELECT NEW.id_user, 'is_super_user', CONVERT(CONVERT(OLD.is_super_user, SIGNED), CHAR), CONVERT(CONVERT(NEW.is_super_user, SIGNED), CHAR), NEW.id_change_set @@ -4810,6 +4847,18 @@ BEGIN # Changed active SELECT NEW.id_user, 'active', CONVERT(CONVERT(OLD.active, SIGNED), CHAR), CONVERT(CONVERT(NEW.active, SIGNED), CHAR), NEW.id_change_set WHERE NOT (OLD.active <=> NEW.active) + UNION + # Changed id_currency_default + SELECT NEW.id_user, 'id_currency_default', CONVERT(OLD.id_currency_default, CHAR), CONVERT(NEW.id_currency_default, CHAR), NEW.id_change_set + WHERE NOT (OLD.id_currency_default <=> NEW.id_currency_default) + UNION + # Changed id_region_default + SELECT NEW.id_user, 'id_region_default', CONVERT(OLD.id_region_default, CHAR), CONVERT(NEW.id_region_default, CHAR), NEW.id_change_set + WHERE NOT (OLD.id_region_default <=> NEW.id_region_default) + UNION + # Changed is_included_VAT_default + SELECT NEW.id_user, 'is_included_VAT_default', CONVERT(CONVERT(OLD.is_included_VAT_default, SIGNED), CHAR), CONVERT(CONVERT(NEW.is_included_VAT_default, SIGNED), CHAR), NEW.id_change_set + WHERE NOT (OLD.is_included_VAT_default <=> NEW.is_included_VAT_default) ; END // DELIMITER ; @@ -5830,22 +5879,11 @@ BEGIN DECLARE v_i_end INT; DECLARE v_current_item VARCHAR(4000); + -- Argument validation + default values - IF a_string IS NULL THEN - SET a_string = ''; - ELSE - SET a_string = TRIM(a_string); - END IF; - IF a_separator IS NULL THEN - SET a_separator = ''; - ELSE - SET a_separator = TRIM(a_separator); - END IF; - /* - IF a_allow_empty IS NULL THEN - SET a_allow_empty = 0; - END IF; - */ + SET a_string := IFNULL(a_string, ''); + SET a_separator := IFNULL(a_separator, ''); + -- Temporary tables DROP TABLE IF EXISTS Split_Temp; @@ -5860,7 +5898,7 @@ BEGIN SET v_has_string = CASE WHEN a_string = '' THEN 0 ELSE 1 END; SET v_has_separator = CASE WHEN a_separator = '' THEN 0 ELSE 1 END; - IF (v_has_string AND v_has_separator) THEN + IF v_has_string THEN SET v_i_start = 1; SET v_i_end = LOCATE(',', a_string); @@ -5912,7 +5950,7 @@ USE PARTSLTD_PROD; CALL p_shop_user_eval ( UUID(), # a_guid - '', # a_id_user + '', # a_ids_user 0, # a_get_inactive_users '1', # a_ids_permission '', # a_ids_access_level @@ -5927,8 +5965,8 @@ DROP PROCEDURE IF EXISTS p_shop_user_eval; DELIMITER // CREATE PROCEDURE p_shop_user_eval ( - IN a_guid VARCHAR(36), - IN a_id_user VARCHAR(200), + IN a_guid BINARY(36), + IN a_ids_user LONGTEXT, IN a_get_inactive_users BIT, IN a_ids_permission VARCHAR(500), IN a_ids_access_level VARCHAR(100), @@ -5951,7 +5989,7 @@ BEGIN DECLARE v_priority_access_level_admin INT; DECLARE v_id_access_level INT; DECLARE v_priority_access_level INT; - DECLARE v_now DATETIME; + DECLARE v_now TIMESTAMP; DECLARE v_ids_row_delete VARCHAR(500); DECLARE v_code_error_data VARCHAR(200); DECLARE v_id_error_data INT; @@ -5970,52 +6008,18 @@ BEGIN -- Parse arguments + get default values - /* - IF a_guid IS NULL THEN - SET a_guid = UUID(); - END IF; - */ - IF a_id_user IS NULL THEN - SET a_id_user = ''; - ELSE - SET a_id_user = TRIM(a_id_user); - END IF; - IF a_get_inactive_users IS NULL THEN - SET a_get_inactive_users = 0; - END IF; - /* - IF a_get_user_permissions IS NULL THEN - SET a_get_user_permissions = 0; - END IF; - */ - IF a_ids_permission IS NULL THEN - SET a_ids_permission = ''; - ELSE - SET a_ids_permission = TRIM(a_ids_permission); - END IF; - IF a_ids_access_level IS NULL THEN - SET a_ids_access_level = ''; - ELSE - SET a_ids_access_level = TRIM(a_ids_access_level); - END IF; - /* - IF a_ids_permutation IS NULL THEN - SET a_ids_permutation = ''; - ELSE - SET a_ids_permutation = TRIM(a_ids_permutation); - END IF; - */ - IF a_ids_product IS NULL THEN - SET a_ids_product = ''; - ELSE - SET a_ids_product = TRIM(a_ids_product); - END IF; + SET a_guid := IFNULL(a_guid, UUID()); + SET a_ids_user := TRIM(IFNULL(a_ids_user, '')); + SET a_get_inactive_users := IFNULL(a_get_inactive_users, 0); + SET a_ids_permission := TRIM(IFNULL(a_ids_permission, '')); + SET a_ids_access_level := TRIM(IFNULL(a_ids_access_level, '')); + SET a_ids_product := TRIM(IFNULL(a_ids_product, '')); -- Permanent Table CREATE TABLE IF NOT EXISTS Shop_User_Eval_Temp ( id_row INT PRIMARY KEY AUTO_INCREMENT NOT NULL, - guid VARCHAR(36) NOT NULL, - id_user VARCHAR(200), + guid BINARY(36) NOT NULL, + id_user INT NULL, id_permission_required INT NOT NULL, CONSTRAINT FK_Shop_User_Eval_Temp_id_permission_required FOREIGN KEY (id_permission_required) @@ -6054,30 +6058,18 @@ BEGIN can_admin BIT -- DEFAULT 0 ); - CREATE TABLE IF NOT EXISTS tmp_Shop_Product_p_Shop_User_Eval ( + CREATE TEMPORARY TABLE IF NOT EXISTS tmp_Shop_Product_p_Shop_User_Eval ( id_row INT PRIMARY KEY AUTO_INCREMENT NOT NULL, id_product INT NOT NULL, - CONSTRAINT FK_tmp_Shop_Product_p_Shop_User_Eval_id_product FOREIGN KEY (id_product) - REFERENCES Shop_Product (id_product), - /* - id_permutation INT NOT NULL, - CONSTRAINT FK_tmp_Shop_Product_p_Shop_User_Eval_id_permutation FOREIGN KEY (id_permutation) - REFERENCES Shop_Product_Permutation (id_permutation), - */ id_access_level_required INT NOT NULL, - CONSTRAINT FK_tmp_Shop_Product_p_Shop_User_Eval_id_access_level_required FOREIGN KEY (id_access_level_required) - REFERENCES Shop_Access_Level (id_access_level), - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, rank_product INT NOT NULL ); - CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( + CREATE TEMPORARY TABLE IF NOT EXISTS tmp_Msg_Error ( display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + 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 ); @@ -6100,7 +6092,7 @@ BEGIN ) ; END IF; - SET v_has_filter_user = CASE WHEN a_id_user = '' THEN 0 ELSE 1 END; + SET v_has_filter_user = CASE WHEN a_ids_user = '' THEN 0 ELSE 1 END; SET a_ids_permission = REPLACE(a_ids_permission, '|', ','); SET v_has_filter_permission = CASE WHEN a_ids_permission = '' THEN 0 ELSE 1 END; SET a_ids_access_level = REPLACE(a_ids_access_level, '|', ','); @@ -6347,10 +6339,10 @@ BEGIN IF NOT EXISTS (SELECT * FROM tmp_Msg_Error WHERE GUID = a_guid) THEN IF v_has_filter_user = 1 THEN /* - SET a_id_user := (SELECT id_user FROM Shop_User WHERE id_user LIKE a_id_user AND active); - SET v_has_filter_user = NOT (a_id_user <=> NULL); + SET a_ids_user := (SELECT id_user FROM Shop_User WHERE id_user LIKE a_ids_user AND active); + SET v_has_filter_user = NOT (a_ids_user <=> NULL); */ - IF ISNULL((SELECT id_user FROM Shop_User WHERE id_user LIKE a_id_user AND active)) THEN -- NOT v_has_filter_user THEN + IF ISNULL((SELECT id_user FROM Shop_User WHERE id_user LIKE a_ids_user AND active)) THEN -- NOT v_has_filter_user THEN INSERT INTO tmp_Msg_Error ( guid, id_type, @@ -6361,10 +6353,10 @@ BEGIN a_guid, (SELECT id_type FROM Shop_Msg_Error_Type WHERE code = v_code_error_data LIMIT 1), v_code_error_data, - CONCAT('Invalid user ID: ', IFNULL(a_id_user, 'NULL')) + CONCAT('Invalid user ID: ', IFNULL(a_ids_user, 'NULL')) ) ; - SET a_id_user = NULL; + SET a_ids_user = NULL; SET v_has_filter_user = 0; ELSE SET v_has_filter_user = 1; @@ -6388,13 +6380,20 @@ BEGIN */ ) SELECT a_guid, - a_id_user, + U.id_user, P.id_permission, AL.priority FROM Shop_Permission P INNER JOIN Shop_Access_Level AL ON P.id_access_level_required = AL.id_access_level - AND AL.active + AND AL.active + CROSS JOIN ( + SELECT id_user + FROM Shop_User U + WHERE 1=1 + AND FIND_IN_SET(U.id_user, a_ids_user) > 0 + AND U.active + ) U WHERE FIND_IN_SET(P.id_permission, a_ids_permission) > 0 ; @@ -6421,7 +6420,7 @@ BEGIN ON t_P.id_access_leveL_required = AL.id_access_level AND AL.active CROSS JOIN Shop_User_Eval_Temp UE_T - ON a_id_user = UE_T.id_user + ON a_ids_user = UE_T.id_user WHERE a_guid = t_P.guid ; @@ -6452,7 +6451,7 @@ BEGIN ON t_P.id_access_leveL_required = AL.id_access_level AND AL.active CROSS JOIN Shop_User_Eval_Temp UE_T - ON a_id_user = UE_T.id_user + ON a_ids_user = UE_T.id_user WHERE a_guid = t_P.guid ; @@ -6504,7 +6503,7 @@ BEGIN INNER JOIN Shop_Access_Level AL ON RPL.id_access_level = AL.id_access_level AND AL.active - WHERE U.id_user = a_id_user + WHERE U.id_user = a_ids_user AND (a_get_inactive_users OR U.active) AND FIND_IN_SET(P.id_permission, a_ids_permission) > 0 # AND v_id_permission = P.id_permission @@ -6533,7 +6532,7 @@ BEGIN UE_T.can_edit = CASE WHEN U.is_super_user THEN 1 ELSE CASE WHEN NOT ISNULL(AL.priority) AND AL.priority <= v_priority_access_level_edit AND AL.priority <= UE_T.priority_access_level_required THEN 1 ELSE 0 END END, UE_T.can_admin = CASE WHEN U.is_super_user THEN 1 ELSE CASE WHEN NOT ISNULL(AL.priority) AND AL.priority <= v_priority_access_level_admin AND AL.priority <= UE_T.priority_access_level_required THEN 1 ELSE 0 END END WHERE UE_T.guid = a_guid - AND UE_T.id_user = a_id_user + AND UE_T.id_user = a_ids_user AND RPL.id_permission = UE_T.id_permission_required # GROUP BY UE_T.id_user ; @@ -6545,7 +6544,7 @@ BEGIN UE_T.can_edit = 0, UE_T.can_admin = 0 WHERE UE_T.guid = a_guid - AND UE_T.id_user = a_id_user + AND UE_T.id_user = a_ids_user # GROUP BY UE_T.id_user ; END IF; @@ -6586,7 +6585,7 @@ select * from shop_product; CALL p_shop_user_eval ( -- '00550ef3-2bfa-11ef-b83e-b42e9986184a', NULL, 0, '2', '1', '1,2,3,4,5,6'); '56c9dfc1-e22f-11ee-aab4-b42e9986184a', # a_guid - '', # a_id_user # 'auth0|6582b95c895d09a70ba10fef', + '', # a_ids_user # 'auth0|6582b95c895d09a70ba10fef', false, # a_get_inactive_users '4,5', # a_ids_permission '1', # a_ids_access_level @@ -6749,259 +6748,245 @@ USE PARTSLTD_PROD; -- Clear previous proc DROP PROCEDURE IF EXISTS p_save_product; +DROP PROCEDURE IF EXISTS p_shop_save_product; -/* DELIMITER // -CREATE PROCEDURE p_save_product ( - IN a_guid VARCHAR(500), - IN a_id_user VARCHAR(200), - IN a_comment VARCHAR(500) +CREATE PROCEDURE p_shop_save_product ( + IN a_guid BINARY(36), + IN a_id_user INT, + IN a_comment VARCHAR(500) ) BEGIN - - -- Argument default values - IF a_ids_category IS NULL THEN - SET a_ids_category = ''; - END IF; - IF a_get_inactive_categories IS NULL THEN - SET a_get_inactive_categories = 0; - END IF; - /* - IF a_get_all_categories IS NULL THEN - SET a_get_all_categories = 0; - END IF; - * - IF a_ids_product IS NULL THEN - SET a_ids_product = ''; - END IF; - IF a_get_inactive_products IS NULL THEN - SET a_get_inactive_products = 0; - END IF; - IF a_get_first_product_only IS NULL THEN - SET a_get_first_product_only = 1; - END IF; - IF a_get_all_products IS NULL THEN - SET a_get_all_products = 0; - END IF; - IF a_ids_image IS NULL THEN - SET a_ids_image = ''; - END IF; - IF a_get_inactive_images IS NULL THEN - SET a_get_inactive_images = 0; - END IF; - IF a_get_first_image_only IS NULL THEN - SET a_get_first_image_only = 1; - END IF; - IF a_get_all_images IS NULL THEN - SET a_get_all_images = 0; - END IF; + 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 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; + INSERT INTO tmp_Msg_Error ( + guid + , id_type + , code + , msg + ) + SELECT + a_guid + , NULL + , @errno + , @text + ; + 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 a_guid := IFNULL(a_guid, UUID()); - -- Temporary tables - CREATE TABLE tmp_Shop_Category ( - id_category INT NOT NULL, - active BIT NOT NULL, - display_order INT NOT NULL, - can_view BIT NOT NULL, - can_edit BIT NOT NULL, - can_admin BIT NOT NULL + CREATE TEMPORARY TABLE tmp_Product ( + id_category INT NOT NULL + , id_product INT NOT NULL + , name VARCHAR(255) NOT NULL + , has_variations BIT NOT NULL + , id_access_level_required INT NOT NULL + , active BIT NOT NULL + , display_order INT NOT NULL + , can_view BIT NULL + , can_edit BIT NULL + , can_admin BIT NULL + , name_error VARCHAR(255) NOT NULL + , is_new BIT NOT NULL ); - - CREATE TABLE tmp_Shop_Product ( - id_category INT NOT NULL, - id_product INT NOT NULL, - active BIT NOT NULL, - display_order INT NOT NULL, - can_view BIT NOT NULL, - can_edit BIT NOT NULL, - can_admin BIT NOT NULL - ); - - CREATE TABLE tmp_Shop_Variation ( - id_variation INT NOT NULL, - id_product INT NOT NULL, - display_order INT NOT NULL - ); - - CREATE TABLE tmp_Shop_Image ( - id_product INT NOT NULL, - id_image INT NOT NULL, - active BIT NOT NULL, - display_order INT NOT NULL - ); - - CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( - display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, - id_type INT NOT NULL, - CONSTRAINT FK_tmp_Msg_Error_id_type + + CREATE TEMPORARY TABLE IF NOT EXISTS tmp_Msg_Error ( + display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT + , guid BIGINT 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 + */ + , code VARCHAR(50) NOT NULL + , msg VARCHAR(4000) NOT NULL ); + - - -- Parse filters - SET a_ids_category = REPLACE(a_ids_category, ',', '|'); - SET a_ids_product = REPLACE(a_ids_product, ',', '|'); - SET v_has_filter_category = CASE WHEN a_ids_category = '' THEN 0 ELSE 1 END; - SET v_has_filter_product = CASE WHEN a_ids_product = '' THEN 0 ELSE 1 END; - - INSERT INTO tmp_Shop_Category ( - id_category, active, display_order + -- Get data from Temp table + INSERT INTO tmp_Product ( + id_category + , id_product + , name + , has_variations + , id_access_level_required + , active + , display_order + , name_error + , is_new ) - SELECT C.id_category, C.active, C.display_order - FROM Shop_Category C - WHERE (NOT v_has_filter_category OR C.id_category LIKE '%' || a_ids_category || '%') - AND (a_get_inactive_categories OR C.active); + SELECT + IFNULL(P_T.id_category, P.id_category) AS id_category + , IFNULL(P_T.id_product, 0) AS id_product + , IFNULL(PT.name, P.name) AS name + , IFNULL(PT.has_variations, P.has_variations) AS has_variations + , IFNULL(PT.id_access_level_required, P.id_access_level_required) AS id_access_level_required + , IFNULL(P_T.active, P.active) AS active + , IFNULL(P_T.display_order, P.display_order) AS display_order + , IFNULL(PT.name, IFNULL(P.name, IFNULL(P_T.id_product, '(No Product)'))) AS name_error + , CASE WHEN IFNULL(P_T.id_product, 0) < 1 THEN 1 ELSE 0 END AS is_new + FROM Shop_Product_Tenp P_T + LEFT JOIN Shop_Product P ON P_T.id_product = P.id_product + ; - INSERT INTO tmp_Shop_Product ( - id_category, id_product, active, display_order + -- Validation + -- Missing mandatory fields + INSERT INTO tmp_Msg_Error ( + guid + , id_type + , code + , msg ) - SELECT P.id_category, P.id_product, P.active, P.display_order - FROM Shop_Product P - INNER JOIN tmp_Shop_Category tC - ON P.id_category = tC.id_category - WHERE (a_get_all_products OR P.id_product LIKE '%' || a_ids_product || '%') - AND (a_get_inactive_products OR P.active); - - IF a_get_first_product_only THEN - DELETE FROM tmp_Shop_Product - WHERE display_order > (SELECT display_order FROM tmp_Shop_Product ORDER BY display_order ASC LIMIT 1); - END IF; - - IF v_has_filter_product THEN - DELETE FROM tmp_Shop_Category - WHERE id_category NOT IN (SELECT DISTINCT id_category FROM tmp_Shop_Product); - END IF; - - INSERT INTO tmp_Shop_Variation ( - id_variation, id_product # , display_order - ) - SELECT P.id_variation, P.id_product # , P.display_order - FROM Shop_Variation V - INNER JOIN tmp_Shop_Product tP - ON V.id_product = tP.id_product - WHERE V.active; - - INSERT INTO tmp_Shop_Image ( - id_product, id_image, active, display_order - ) - SELECT I.id_product, I.id_image, I.active, I.display_order - FROM Shop_Image I - INNER JOIN tmp_Shop_Product tP - ON I.id_image = tP.id_image - WHERE (a_get_all_images OR I.id_image LIKE '%' || a_ids_image || '%') - AND (a_get_inactive_images OR I.active); - - IF a_get_first_image_only THEN - DELETE FROM tmp_Shop_Image - WHERE display_order > (SELECT display_order FROM tmp_Shop_Image ORDER BY display_order ASC LIMIT 1); - END IF; - - IF v_has_filter_image THEN - DELETE FROM tmp_Shop_Product - WHERE id_product NOT IN (SELECT DISTINCT id_product FROM tmp_Shop_Image); - DELETE FROM tmp_Shop_Category - WHERE id_category NOT IN (SELECT DISTINCT id_category FROM tmp_Shop_Product); - END IF; + -- id_category + SELECT + a_guid AS GUID + , v_id_type_error_bad_data + , v_code_error_bad_data + , CONCAT('The following product(s) do not have a category: ', GROUP_CONCAT(t_P.name_error SEPARATOR ', ')) + FROM tmp_Product t_P + WHERE ISNULL(t_P.id_category) + UNION + -- name + SELECT + a_guid AS GUID + , v_id_type_error_bad_data + , v_code_error_bad_data + , CONCAT('The following product(s) do not have a name: ', GROUP_CONCAT(t_P.name_error SEPARATOR ', ')) + FROM tmp_Product t_P + WHERE ISNULL(t_P.name) + UNION + -- has_variations + SELECT + a_guid AS GUID + , v_id_type_error_bad_data + , v_code_error_bad_data + , CONCAT('The following product(s) do not have a has-variations setting: ', GROUP_CONCAT(t_P.name_error SEPARATOR ', ')) + FROM tmp_Product t_P + WHERE ISNULL(t_P.has_variations) + UNION + -- id_access_level_required + SELECT + a_guid AS GUID + , v_id_type_error_bad_data + , v_code_error_bad_data + , CONCAT('The following product(s) do not have a required access level ID: ', GROUP_CONCAT(t_P.name_error SEPARATOR ', ')) + FROM tmp_Product t_P + WHERE ISNULL(t_P.id_access_level_required) + UNION + -- display_order + SELECT + a_guid AS GUID + , v_id_type_error_bad_data + , v_code_error_bad_data + , CONCAT('The following product(s) do not have a display order: ', GROUP_CONCAT(t_P.name_error SEPARATOR ', ')) + FROM tmp_Product t_P + WHERE ISNULL(t_P.display_order) + ; -- Permissions - IF EXISTS (SELECT * FROM tmp_Shop_Category LIMIT 1) THEN - SET v_guid_permission = UUID(); - SET v_id_user = CURRENT_USER(); - SET v_id_permission_product = (SELECT id_permission FROM Shop_Permission WHERE code = 'STORE_PRODUCT' LIMIT 1); - SET v_ids_product_permission = (SELECT GROUP_CONCAT(item SEPARATOR '|') FROM tmp_Shop_Product); - - CALL p_shop_user_eval(v_guid_permission, v_id_user, v_id_permission_product, v_ids_product_permission); - - UPDATE tmp_Shop_Product tP - INNER JOIN Shop_User_Eval_Temp TP - ON tP.id_product = TP.id_product - AND TP.GUID = v_guid_permission - SET tP.can_view = TP.can_view, - tP.can_edit = TP.can_edit, - tP.can_admin = TP.can_admin; - - CALL p_shop_user_eval_clear_temp(v_guid_permission); + 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(item SEPARATOR ',') FROM tmp_Shop_Product WHERE is_new = 0); + IF NOT ISNULL(v_ids_product_permission) THEN + SET v_id_permission_product = (SELECT id_permission FROM Shop_Permission WHERE code = 'STORE_PRODUCT' LIMIT 1); + + CALL p_shop_user_eval(a_guid, a_id_user, v_id_permission_product, v_ids_product_permission); + + UPDATE tmp_Product t_P + INNER JOIN Shop_User_Eval_Temp UE_T + ON t_P.id_product = UE_T.id_product + AND UE_T.GUID = a_guid + SET + t_P.can_view = UE_T.can_view + , t_P.can_edit = UE_T.can_edit + , t_P.can_admin = UE_T.can_admin + ; + + CALL p_shop_user_eval_clear_temp(a_guid); + END IF; END IF; - -- Returns - SET v_now = NOW(); + IF NOT EXISTS (SELECT * FROM tmp_Msg_Error LIMIT 1) THEN + -- Start the transaction + START TRANSACTION; + + -- Your transaction logic goes here + 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 P + INNER JOIN tmp_Product t_P ON P.id_product = t_P.id_product + SET + P.id_category = t_P.id_category + , P.name = t_P.name + , P.has_variations = t_P.has_variations + , P.id_access_level_required = t_P.id_access_level_required + , P.display_order = t_P.display_order + , P.id_change_set = v_id_change_set + ; + END IF; + + INSERT INTO Shop_Product ( + id_category + , name + , has_variations + , id_access_level_required + , display_order + , created_by + , created_on + ) + SELECT + t_P.id_category AS id_category + , t_P.name AS name + , t_P.has_variations AS has_variations + , t_P.id_access_level_required AS id_access_level_required + , t_P.display_order AS display_order + , a_id_user AS created_by + , v_now AS created_on + FROM tmp_Product t_P + WHERE is_new = 1 + ; + + -- If we reach here without error, commit the transaction + COMMIT; + END IF; - # Categories - SELECT ( - tC.id_category, - C.name, - C.description, - tC.can_view, - tC.can_edit, - tC.can_admin - ) - FROM tmp_Shop_Category tC - INNER JOIN Shop_Category C - ON tC.id_category = C.id_category - ; + SELECT * FROM tmp_Msg_Error; - # Products - SELECT - tP.id_product, - P.name, - P.price, - P.description, - C.id_category, - P.lead_time, - 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, - 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 - ; - - # Variations - SELECT - PVL.id_variation, - tV.id_product, - V.code, - V.name, - PVL.display_order - FROM tmp_Shop_Product tV - INNER JOIN Shop_Product_Variation_Link PVL - ON tV.id_product = PVL.id_product - INNER JOIN Shop_Variation V - ON PVL.id_variation = V.id_variation - WHERE V.active - AND PVL.active - ; - - # Images - SELECT - tI.id_image, - tI.id_product, - I.url, - PIL.display_order - FROM tmp_Shop_Image tI - INNER JOIN Shop_Product_Image_Link PIL - ON tI.id_product = PIL.id_product - WHERE I.active - AND PIL.active - ; + DROP TEMPORARY TABLE IF EXISTS tmp_Product; + DROP TEMPORARY TABLE IF EXISTS tmp_Msg_Error; END // DELIMITER ; -*/ + USE PARTSLTD_PROD; @@ -7011,7 +6996,7 @@ DROP PROCEDURE IF EXISTS p_shop_get_many_product; DELIMITER // CREATE PROCEDURE p_shop_get_many_product ( - IN a_id_user VARCHAR(200), + IN a_id_user INT, IN a_get_all_category BIT, IN a_get_inactive_category BIT, IN a_get_first_category_only BIT, @@ -7055,14 +7040,14 @@ BEGIN DECLARE v_has_filter_delivery_region BIT; DECLARE v_has_filter_currency BIT; DECLARE v_has_filter_discount BIT; - DECLARE v_guid VARCHAR(36); + DECLARE v_guid BINARY(36); # DECLARE v_id_user VARCHAR(100); DECLARE v_ids_permutation_unavailable VARCHAR(4000); DECLARE v_id_permission_product INT; DECLARE v_ids_product_permission VARCHAR(4000); -- DECLARE v_ids_permutation_permission VARCHAR(4000); DECLARE v_id_access_level_view INT; - -- DECLARE v_now DATETIME; + -- DECLARE v_now TIMESTAMP; DECLARE v_id_minimum INT; SET v_guid := UUID(); @@ -7293,7 +7278,7 @@ BEGIN CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, id_type INT NOT NULL, CONSTRAINT FK_tmp_Msg_Error_id_type FOREIGN KEY (id_type) @@ -8193,13 +8178,13 @@ DROP PROCEDURE IF EXISTS p_shop_get_many_stripe_product_new; DELIMITER // CREATE PROCEDURE p_shop_get_many_stripe_product_new ( - IN a_id_user VARCHAR(200) + IN a_id_user INT ) BEGIN DECLARE v_has_filter_user BIT; DECLARE v_code_error_data VARCHAR(200); DECLARE v_code_error_permission VARCHAR(200); - DECLARE v_guid VARCHAR(36); + DECLARE v_guid BINARY(36); SET v_code_error_data := (SELECT code FROM Shop_Msg_Error_Type WHERE id_type = 1); SET v_code_error_permission := (SELECT code FROM Shop_Msg_Error_Type WHERE id_type = 2); @@ -8219,7 +8204,7 @@ BEGIN DROP TABLE IF EXISTS tmp_Shop_User; CREATE TABLE tmp_Shop_User( - id_user VARCHAR(200) NOT NULL PRIMARY KEY, + id_user INT NOT NULL PRIMARY KEY, CONSTRAINT FK_tmp_Shop_User_id_user FOREIGN KEY (id_user) REFERENCES Shop_User(id_user), @@ -8244,7 +8229,7 @@ BEGIN CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( # IF NOT EXISTS display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, code VARCHAR(50) NOT NULL, # CONSTRAINT chk_tmp_Msg_Error_code CHECK (code IN (SELECT code FROM Shop_Msg_Error_Type)), /* @@ -8495,7 +8480,7 @@ DROP TABLE IF EXISTS tmp_Msg_Error; DELIMITER // CREATE PROCEDURE p_shop_save_permutation ( IN a_guid VARCHAR(500), - IN a_id_user VARCHAR(200), + IN a_id_user INT, IN a_id_order INT, -- IN a_id_supplier_ordered INT, IN a_id_currency_cost INT, @@ -8507,7 +8492,7 @@ BEGIN 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 VARCHAR(36); + 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; @@ -8578,7 +8563,7 @@ BEGIN CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, id_type INT NOT NULL, CONSTRAINT FK_tmp_Msg_Error_id_type FOREIGN KEY (id_type) @@ -9096,7 +9081,7 @@ DROP PROCEDURE IF EXISTS p_shop_get_many_stock_item; DELIMITER // CREATE PROCEDURE p_shop_get_many_stock_item ( - IN a_id_user VARCHAR(200), + IN a_id_user INT, IN a_get_all_category BIT, IN a_get_inactive_category BIT, IN a_get_first_category_only BIT, @@ -9125,7 +9110,7 @@ CREATE PROCEDURE p_shop_get_many_stock_item ( IN a_get_inactive_location_storage BIT, IN a_get_first_location_storage_only BIT, IN a_ids_location_storage TEXT, - IN a_date_received_to DATETIME, + IN a_date_received_to TIMESTAMP, IN a_get_sealed_stock_item_only BIT, IN a_get_unsealed_stock_item_only BIT, IN a_get_expired_stock_item_only BIT, @@ -9143,15 +9128,15 @@ BEGIN DECLARE v_has_filter_region_storage BIT; DECLARE v_has_filter_plant_storage BIT; DECLARE v_has_filter_location_storage BIT; - DECLARE v_guid VARCHAR(36); + DECLARE v_guid BINARY(36); -- DECLARE v_ids_permutation_unavailable LONGTEXT; DECLARE v_id_permission_product INT; DECLARE v_ids_product_permission LONGTEXT; -- DECLARE v_ids_permutation_permission VARCHAR(4000); DECLARE v_id_access_level_view INT; - -- DECLARE v_now DATETIME; + -- DECLARE v_now TIMESTAMP; -- DECLARE v_id_minimum INT; - DECLARE v_now DATETIME; + DECLARE v_now TIMESTAMP; SET v_guid := UUID(); SET v_id_access_level_view := (SELECT id_access_level FROM Shop_Access_Level WHERE code = 'VIEW'); @@ -9197,25 +9182,32 @@ BEGIN SET a_get_nonconsumed_stock_item_only := IFNULL(a_get_nonconsumed_stock_item_only, 0); -- Temporary tables - DROP TEMPORARY TABLE IF EXISTS tmp_Stock_Item; - DROP TEMPORARY TABLE IF EXISTS tmp_Product; - DROP TEMPORARY TABLE IF EXISTS tmp_Category; + DROP TABLE IF EXISTS tmp_Region_Storage; + DROP TABLE IF EXISTS tmp_Plant_Storage; + DROP TABLE IF EXISTS tmp_Location_Storage; + DROP TABLE IF EXISTS tmp_Stock_Item; + DROP TABLE IF EXISTS tmp_Permutation; + DROP TABLE IF EXISTS tmp_Product; + DROP TABLE IF EXISTS tmp_Category; + DROP TABLE IF EXISTS tmp_Msg_Error; CREATE TEMPORARY TABLE tmp_Category ( - id_category INT NOT NULL, - CONSTRAINT FK_tmp_Category_id_category + id_category INT NOT NULL + /* + , CONSTRAINT FK_tmp_Category_id_category FOREIGN KEY (id_category) REFERENCES Shop_Category(id_category) - /* + / active BIT NOT NULL, display_order INT NOT NULL, can_view BIT, can_edit BIT, can_admin BIT */ + , rank_category INT NOT NULL ); - CREATE TABLE tmp_Product ( + CREATE TEMPORARY TABLE tmp_Product ( /* id_category INT NOT NULL, CONSTRAINT FK_tmp_Shop_Product_id_category @@ -9223,9 +9215,11 @@ BEGIN REFERENCES Shop_Category(id_category), */ id_product INT NOT NULL + /* , CONSTRAINT FK_tmp_Product_id_product FOREIGN KEY (id_product) REFERENCES Shop_Product(id_product) + */ -- product_has_variations BIT NOT NULL, /* id_permutation INT NULL, @@ -9262,77 +9256,114 @@ BEGIN , can_edit BIT , can_admin BIT */ + , rank_product INT NOT NULL ); CREATE TEMPORARY TABLE tmp_Permutation ( - id_permutation INT NOT NULL, + id_permutation INT NOT NULL + /* CONSTRAINT FK_tmp_Permutation_id_permutation FOREIGN KEY (id_permutation) REFERENCES Shop_Product_Permutation(id_permutation) + */ + , rank_permutation INT NOT NULL ); CREATE TEMPORARY TABLE tmp_Stock_Item ( id_stock INT NOT NULL PRIMARY KEY, - id_permutation INT NOT NULL, + id_permutation INT NOT NULL + /* CONSTRAINT FK_tmp_Stock_Item_id_permutation FOREIGN KEY (id_permutation) REFERENCES Shop_Product_Permutation(id_permutation), - id_product INT NOT NULL, + */ + , id_product INT NOT NULL + /* CONSTRAINT FK_tmp_Stock_Item_id_product FOREIGN KEY (id_product) REFERENCES Shop_Product(id_product), - id_category INT NOT NULL, + */ + , id_category INT NOT NULL + /* CONSTRAINT FK_tmp_Stock_Item_id_category FOREIGN KEY (id_category) REFERENCES Shop_Category(id_category), - date_purchased DATETIME NOT NULL, - date_received DATETIME NULL, - id_location_storage INT NOT NULL, + */ + , date_purchased TIMESTAMP NOT NULL + , date_received TIMESTAMP NULL + , id_location_storage INT NOT NULL + /* CONSTRAINT FK_tmp_Stock_Item_id_location_storage FOREIGN KEY (id_location_storage) REFERENCES Shop_Storage_Location(id_location), - id_currency_cost INT NOT NULL, + */ + , id_currency_cost INT NOT NULL + /* CONSTRAINT FK_tmp_Stock_Item_id_currency FOREIGN KEY (id_currency_cost) REFERENCES Shop_Currency(id_currency), - cost_local_VAT_incl FLOAT NOT NULL, - cost_local_VAT_excl FLOAT NOT 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 + */ + , cost_local_VAT_incl FLOAT NOT NULL + , cost_local_VAT_excl FLOAT NOT NULL + , is_sealed BIT NOT NULL DEFAULT 1 + , date_unsealed TIMESTAMP NULL + , date_expiration TIMESTAMP NOT NULL + , is_consumed BIT NOT NULL DEFAULT 0 + , date_consumed TIMESTAMP NULL + , active_stock_item BIT NOT NULL DEFAULT 1 + , active_permutation BIT NOT NULL + , active_product BIT NOT NULL + , active_category BIT NOT NULL + , rank_stock_item INT NOT NULL + , display_order_permutation INT NOT NULL + , display_order_product INT NOT NULL + , display_order_category INT NOT NULL + , can_view BIT NULL + , can_edit BIT NULL + , can_admin BIT NULL ); CREATE TEMPORARY TABLE tmp_Region_Storage ( - id_region INT NOT NULL PRIMARY KEY, + id_region INT NOT NULL PRIMARY KEY + /* CONSTRAINT FK_tmp_Region_Storage_id_region FOREIGN KEY (id_region) REFERENCES Shop_Region(id_region) + */ + , rank_region INT NOT NULL ); CREATE TEMPORARY TABLE tmp_Plant_Storage ( - id_plant INT NOT NULL PRIMARY KEY, + id_plant INT NOT NULL PRIMARY KEY + /* CONSTRAINT FK_tmp_Plant_Storage_id_plant FOREIGN KEY (id_plant) REFERENCES Shop_Plant(id_plant) + */ + , rank_plant INT NOT NULL + , id_region INT NOT NULL ); CREATE TEMPORARY TABLE tmp_Location_Storage ( - id_location INT NOT NULL PRIMARY KEY, + id_location INT NOT NULL PRIMARY KEY + /* CONSTRAINT FK_tmp_Location_Storage_id_location FOREIGN KEY (id_location) REFERENCES Shop_Location_Storage(id_location) + */ + , rank_location INT NOT NULL + , id_plant INT NOT NULL ); CREATE TEMPORARY TABLE IF NOT EXISTS tmp_Msg_Error ( display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + 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 ); @@ -9366,9 +9397,11 @@ BEGIN date_received, id_location_storage, id_currency_cost, + /* symbol_currency_cost, code_currency_cost, - cost_local_VAT_incl, + */ + cost_local_VAT_incl, cost_local_VAT_excl, is_sealed, date_unsealed, @@ -9381,6 +9414,7 @@ BEGIN PP.id_permutation, P.id_product, P.id_category, + SI.active AS active_stock_item, PP.active AS active_permutation, P.active AS active_product, C.active AS active_category, @@ -9392,9 +9426,11 @@ BEGIN SI.date_received, SI.id_location_storage, SI.id_currency_cost, - CURRENCY.symbol AS symbol_currency_cost, + /* + CURRENCY.symbol AS symbol_currency_cost, CURRENCY.code AS code_currency_cost, - SI.cost_local_VAT_incl, + */ + SI.cost_local_VAT_incl, SI.cost_local_VAT_excl, SI.is_sealed, SI.date_unsealed, @@ -9404,9 +9440,7 @@ BEGIN FROM Shop_Stock_Item SI INNER JOIN Shop_Product_Permutation PP ON SI.id_permutation = PP.id_permutation INNER JOIN Shop_Product P ON PP.id_product = P.id_product - INNER JOIN Shop_Category C ON P.id_category = C.id_category - INNER JOIN Shop_Currency CURRENCY ON SI.id_currency_cost = CURRENCY.id_currency - + INNER JOIN Shop_Category C ON P.id_category = C.id_category WHERE # stock items ( @@ -9495,13 +9529,16 @@ BEGIN -- Permutations INSERT INTO tmp_Permutation ( - id_permutation + id_permutation, + rank_permutation ) - SELECT DISTINCT t_SI.id_permutation + SELECT + DISTINCT t_SI.id_permutation + , RANK() OVER (ORDER BY id_permutation) AS rank_permutation FROM tmp_Stock_Item t_SI ; IF a_get_first_product_only THEN - DELETE FROM tmp_Shop_Product t_P + DELETE FROM tmp_Product t_P WHERE t_P.rank_permutation > 1 ; END IF; @@ -9509,27 +9546,33 @@ BEGIN -- Products INSERT INTO tmp_Product ( - id_product + id_product, + rank_product ) - SELECT DISTINCT t_SI.id_product + SELECT + DISTINCT t_SI.id_product + , RANK() OVER (ORDER BY id_product) AS rank_product FROM tmp_Stock_Item t_SI ; IF a_get_first_product_only THEN - DELETE FROM tmp_Shop_Product t_P - WHERE t_P.rank_permutation > 1 + DELETE FROM tmp_Product t_P + WHERE t_P.rank_product > 1 ; END IF; -- Categories - INSERT INTO tmp_Shop_Category ( - id_category + INSERT INTO tmp_Category ( + id_category, + rank_category ) - SELECT DISTINCT t_SI.id_category + SELECT + DISTINCT t_SI.id_category + , RANK() OVER (ORDER BY id_category) AS rank_category FROM tmp_Stock_Item t_SI ; IF a_get_first_category_only THEN - DELETE FROM tmp_Shop_Category t_C + DELETE FROM tmp_Category t_C WHERE t_C.rank_category > 1 ; END IF; @@ -9537,14 +9580,15 @@ BEGIN -- Storage Regions INSERT INTO tmp_Region_Storage ( id_region + , rank_region ) WITH RECURSIVE Recursive_CTE_Region_Storage AS ( SELECT - DR.id_region AS id_region_parent, + R.id_region AS id_region_parent, NULL AS id_region_child FROM tmp_Stock_Item t_SI -- INNER JOIN tmp_Stock_Item t_SI ON SL.id_location = t_SI.id_location_storage - INNER JOIN Shop_Storage_Location SL ON t_SI.id_location = SL.id_location_storage + INNER JOIN Shop_Storage_Location SL ON t_SI.id_location_storage = SL.id_location INNER JOIN Shop_Plant P ON SL.id_plant = P.id_plant INNER JOIN Shop_Address A ON P.id_address = A.id_address INNER JOIN Shop_Region R @@ -9565,13 +9609,13 @@ BEGIN INNER JOIN Recursive_CTE_Region_Storage r_RS ON RB.id_region_parent = r_RS.id_region_child AND ( - a_get_inactive_delivery_region + a_get_inactive_region_storage OR RB.active = 1 ) ) SELECT - R.id_region, - RANK() OVER (ORDER BY DR.id_region) AS rank_region + DISTINCT R.id_region, + RANK() OVER (ORDER BY R.id_region) AS rank_region FROM Shop_Region R INNER JOIN Recursive_CTE_Region_Storage r_RS ON R.id_region = r_RS.id_region_parent @@ -9585,17 +9629,20 @@ BEGIN -- Plants INSERT INTO tmp_Plant_Storage ( - id_plant, - rank_plant + id_plant + , rank_plant + , id_region ) SELECT - DISTINCT P.id_plant, - RANK() OVER (ORDER BY P.id_plant) AS rank_plant + DISTINCT P.id_plant + , RANK() OVER (ORDER BY P.id_plant) AS rank_plant + , A.id_region FROM tmp_Stock_Item t_SI INNER JOIN Shop_Storage_Location SL ON t_SI.id_location_storage = SL.id_location INNER JOIN Shop_Plant P ON SL.id_plant = P.id_plant - ; - IF a_get_first_plant_only THEN + INNER JOIN Shop_Address A ON P.id_address = A.id_address + ; + IF a_get_first_plant_storage_only THEN DELETE FROM tmp_Plant_Storage t_P WHERE t_P.rank_plant > 1 ; @@ -9604,6 +9651,8 @@ BEGIN -- Storage Locations INSERT INTO tmp_Location_Storage ( id_location + , rank_location + , id_plant ) WITH RECURSIVE Recursive_CTE_Location_Storage AS ( SELECT @@ -9612,7 +9661,7 @@ BEGIN FROM tmp_Stock_Item t_SI -- INNER JOIN tmp_Stock_Item t_SI ON SL.id_location = t_SI.id_location_storage INNER JOIN Shop_Storage_Location SL - ON t_SI.id_location = SL.id_location_storage + ON t_SI.id_location_storage = SL.id_location AND ( a_get_all_location_storage OR FIND_IN_SET(SL.id_location, a_ids_location_storage) > 0 @@ -9623,19 +9672,20 @@ BEGIN ) UNION SELECT - LB.id_location_parent, - LB.id_location_child - FROM Shop_Location_Branch LB + SLB.id_location_parent, + SLB.id_location_child + FROM Shop_Storage_Location_Branch SLB INNER JOIN Recursive_CTE_Location_Storage r_LS - ON LB.id_location_parent = r_LS.id_location_child + ON SLB.id_location_parent = r_LS.id_location_child AND ( a_get_inactive_location_storage - OR LB.active = 1 + OR SLB.active = 1 ) ) SELECT - SL.id_location, - RANK() OVER (ORDER BY SL.id_location) AS rank_location + DISTINCT SL.id_location + , RANK() OVER (ORDER BY SL.id_location) AS rank_location + , SL.id_plant FROM Shop_Storage_Location SL INNER JOIN Recursive_CTE_Location_Storage r_LS ON SL.id_location = r_LS.id_location_parent @@ -9661,7 +9711,7 @@ BEGIN -- select * from Shop_User_Eval_Temp; - UPDATE tmp_Shop_Stock_Item t_SI + UPDATE tmp_Stock_Item t_SI INNER JOIN Shop_User_Eval_Temp UE_T ON t_SI.id_product = UE_T.id_product AND UE_T.GUID = v_guid @@ -9737,14 +9787,16 @@ BEGIN INNER JOIN tmp_Permutation t_PP ON t_SI.id_permutation = t_PP.id_permutation INNER JOIN tmp_Product t_P ON t_SI.id_product = t_P.id_product INNER JOIN tmp_Category t_C ON t_SI.id_category = t_C.id_category - INNER JOIN tmp_Region_Storage t_RS ON t_LS.id_region = t_RS.id_region - INNER JOIN tmp_Plant_Storage t_PS ON t_LS.id_plant = t_PS.id_plant INNER JOIN tmp_Location_Storage t_LS ON t_SI.id_location_storage = t_LS.id_location + INNER JOIN tmp_Plant_Storage t_PS ON t_LS.id_plant = t_PS.id_plant + INNER JOIN Shop_Plant P ON t_PS.id_plant = P.id_plant + INNER JOIN Shop_Address A ON P.id_address = A.id_address + INNER JOIN tmp_Region_Storage t_RS ON A.id_region = t_RS.id_region INNER JOIN Shop_Storage_Location SL ON t_LS.id_location = SL.id_location INNER JOIN Shop_Currency CURRENCY ON t_SI.id_currency_cost = CURRENCY.id_currency WHERE IFNULL(t_SI.can_view, 0) = 1 - ORDER BY t_P.rank_permutation + ORDER BY t_SI.rank_stock_item ; # Variations @@ -9763,13 +9815,13 @@ BEGIN FROM Shop_Variation V INNER JOIN Shop_Variation_Type VT ON V.id_type = VT.id_type INNER JOIN Shop_Product_Permutation_Variation_Link PPVL ON V.id_variation = PPVL.id_variation - INNER JOIN tmp_Shop_Stock_Item t_SI ON PPVL.id_permutation = t_SI.id_permutation + INNER JOIN tmp_Stock_Item t_SI ON PPVL.id_permutation = t_SI.id_permutation INNER JOIN tmp_Permutation t_PP ON t_SI.id_permutation = t_PP.id_permutation INNER JOIN tmp_Product t_P ON t_SI.id_product = t_P.id_product INNER JOIN tmp_Category t_C ON t_SI.id_category = t_C.id_category - INNER JOIN tmp_Region_Storage t_RS ON t_LS.id_region = t_RS.id_region - INNER JOIN tmp_Plant_Storage t_PS ON t_LS.id_plant = t_PS.id_plant INNER JOIN tmp_Location_Storage t_LS ON t_SI.id_location_storage = t_LS.id_location + INNER JOIN tmp_Plant_Storage t_PS ON t_LS.id_plant = t_PS.id_plant + INNER JOIN tmp_Region_Storage t_RS ON t_PS.id_region = t_RS.id_region WHERE V.active AND PPVL.active @@ -9812,17 +9864,16 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp_Plant_Storage; DROP TEMPORARY TABLE IF EXISTS tmp_Location_Storage; DROP TEMPORARY TABLE IF EXISTS tmp_Stock_Item; - DROP TEMPORARY TABLE IF EXISTS tmp_Shop_Product; - DROP TEMPORARY TABLE IF EXISTS tmp_Shop_Category; + DROP TEMPORARY TABLE IF EXISTS tmp_Permutation; + DROP TEMPORARY TABLE IF EXISTS tmp_Product; + DROP TEMPORARY TABLE IF EXISTS tmp_Category; DROP TEMPORARY TABLE IF EXISTS tmp_Msg_Error; END // DELIMITER ; - /* - CALL p_shop_get_many_stock_item ( - '', # a_id_user + 0, # a_id_user 1, # a_get_all_category 0, # a_get_inactive_category 0, # a_get_first_category_only @@ -9859,6 +9910,8 @@ CALL p_shop_get_many_stock_item ( 0, # a_get_consumed_stock_item_only 0 # a_get_nonconsumed_stock_item_only ); + + DROP TABLE IF EXISTS tmp_Msg_Error; select * from shop_image; @@ -9891,13 +9944,13 @@ DROP PROCEDURE IF EXISTS p_shop_get_many_stripe_price_new; DELIMITER // CREATE PROCEDURE p_shop_get_many_stripe_price_new ( - IN a_id_user VARCHAR(200) + IN a_id_user INT ) BEGIN DECLARE v_has_filter_user BIT; DECLARE v_code_error_data VARCHAR(200); DECLARE v_code_error_permission VARCHAR(200); - DECLARE v_guid VARCHAR(36); + DECLARE v_guid BINARY(36); SET v_code_error_data := (SELECT code FROM Shop_Msg_Error_Type WHERE id_type = 1); SET v_code_error_permission := (SELECT code FROM Shop_Msg_Error_Type WHERE id_type = 2); @@ -9918,7 +9971,7 @@ BEGIN DROP TABLE IF EXISTS tmp_Shop_User; CREATE TABLE tmp_Shop_User( - id_user VARCHAR(200) NOT NULL PRIMARY KEY, + id_user INT NOT NULL PRIMARY KEY, CONSTRAINT FK_tmp_Shop_User_id_user FOREIGN KEY (id_user) REFERENCES Shop_User(id_user), @@ -9947,7 +10000,7 @@ BEGIN CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( # IF NOT EXISTS display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, code VARCHAR(50) NOT NULL, # CONSTRAINT chk_tmp_Msg_Error_code CHECK (code IN (SELECT code FROM Shop_Msg_Error_Type)), /* @@ -10137,7 +10190,7 @@ DROP PROCEDURE IF EXISTS p_shop_edit_user; DELIMITER // CREATE PROCEDURE p_shop_edit_user ( - IN a_id_user VARCHAR(200), + IN a_id_user INT, IN a_name VARCHAR(255), IN a_email VARCHAR(254), IN a_email_verified BIT @@ -10146,7 +10199,7 @@ BEGIN -- Argument redeclaration -- Variable declaration DECLARE v_has_filter_user BIT; - -- DECLARE v_now DATETIME; + -- DECLARE v_now TIMESTAMP; -- Argument validation + default values @@ -10174,7 +10227,7 @@ BEGIN DROP TABLE IF EXISTS tmp_Shop_User; CREATE TABLE tmp_Shop_User ( - id_user VARCHAR(200) NOT NULL, + id_user INT NOT NULL, CONSTRAINT FK_tmp_Shop_User_id_user FOREIGN KEY (id_user) REFERENCES Shop_User(id_user), @@ -10299,6 +10352,222 @@ CALL p_shop_edit_user ( USE PARTSLTD_PROD; + +-- Clear previous proc +DROP PROCEDURE IF EXISTS p_get_many_user; + + +DELIMITER // +CREATE PROCEDURE p_get_many_user ( + IN a_id_user INT + , IN a_get_all_user BIT + , IN a_get_inactive_user BIT + , IN a_get_first_user_only BIT + , IN a_ids_user LONGTEXT + , IN a_ids_user_auth0 LONGTEXT +) +BEGIN + DECLARE v_id_access_level_view INT; + DECLARE v_id_permission_store_admin INT; + DECLARE v_id_permission_user INT; + DECLARE v_id_permission_user_admin INT; + DECLARE v_now TIMESTAMP; + DECLARE v_id_minimum INT; + DECLARE v_code_error_data VARCHAR(50); + DECLARE v_id_type_error_data INT; + DECLARE v_has_filter_user BIT; + DECLARE v_guid BINARY(36); + + SET v_guid := UUID(); + SET v_id_access_level_view := (SELECT id_access_level FROM Shop_Access_Level WHERE code = 'VIEW' LIMIT 1); + SET v_id_permission_store_admin := (SELECT id_permission FROM Shop_Permission WHERE code = 'STORE_ADMIN' LIMIT 1); + SET v_id_permission_user := (SELECT id_permission FROM Shop_Permission WHERE code = 'STORE_USER' LIMIT 1); + SET v_id_permission_user_admin := (SELECT id_permission FROM Shop_Permission WHERE code = 'STORE_USER_ADMIN' LIMIT 1); + SET v_code_error_data := (SELECT code FROM Shop_Msg_Error_Type WHERE code = 'BAD_DATA' LIMIT 1); + SET v_id_type_error_data := (SELECT id_type FROM Shop_Msg_Error_Type WHERE code = v_code_error_data LIMIT 1); + + SET a_ids_user := TRIM(IFNULL(a_ids_user, '')); + SET a_ids_user_auth0 := TRIM(IFNULL(a_ids_user_auth0, '')); + + DROP TEMPORARY TABLE IF EXISTS tmp_User; + DROP TEMPORARY TABLE IF EXISTS tmp_Msg_Error; + + CREATE TEMPORARY TABLE tmp_User ( + id_user INT NOT NULL, + rank_user INT NULL + ); + + CREATE TEMPORARY TABLE tmp_Msg_Error ( + display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, + guid BINARY(36) NOT NULL, + id_type INT NOT NULL, + code VARCHAR(50) NOT NULL, + msg VARCHAR(4000) NOT NULL + ); + + + SET v_has_filter_user := CASE WHEN a_ids_user = '' AND a_ids_user_auth0= '' THEN 0 ELSE 1 END; + + IF v_has_filter_user THEN + INSERT INTO tmp_User ( + id_user + -- , active + , rank_user + ) + SELECT + DISTINCT U.id_user + -- S.active + , RANK() OVER (ORDER BY id_user ASC) AS rank_user + FROM Shop_User U + WHERE 1=1 + AND ( + FIND_IN_SET(U.id_user, a_ids_user) > 0 + OR FIND_IN_SET(U.id_user_auth0, a_ids_user_auth0) > 0 + ) + AND ( + a_get_inactive_user + OR U.active + ) + /*Shop_User_Eval_Temp UE_T + WHERE 1=1 + AND UE_T.guid = v_guid + AND UE_T.active = 1 + */ + ; + + IF a_get_first_user_only THEN + DELETE FROM tmp_User t_U + WHERE t_U.rank_user > 1 + ; + END IF; + END IF; + + -- Permissions + IF NOT EXISTS (SELECT * FROM tmp_Msg_Error LIMIT 1) THEN + -- SELECT v_guid, a_id_user, false, v_id_permission_product, v_id_access_level_view, v_ids_permutation_permission; + -- select * from Shop_User_Eval_Temp; + + CALL p_shop_user_eval( + v_guid, -- guid + a_id_user, -- ids_user + FALSE, -- get_inactive_user + CONCAT(v_id_permission_user, ',', v_id_permission_user_admin, ',', v_id_permission_store_admin), -- ids_permission + v_id_access_level_view, -- ids_access_level + '' -- ids_product + ); + + -- select * from Shop_User_Eval_Temp; + + IF NOT EXISTS ( + SELECT can_view + FROM Shop_User_Eval_Temp UE_T + WHERE 1=1 + AND UE_T.GUID = v_guid + AND UE_T.id_permission_required = v_id_permission_user + ) THEN + INSERT INTO tmp_Msg_Error ( + guid, + id_type, + code, + msg + ) + VALUES ( + v_guid, + v_id_type_error_data, + v_code_error_data, + CONCAT('You do not have view permissions for ', (SELECT name FROM Shop_Permission WHERE id_permission = v_id_permission_user LIMIT 1)) + ) + ; + END IF; + END IF; + + + -- Returns + IF EXISTS (SELECT * FROM tmp_Msg_Error WHERE GUID = v_guid) THEN + DELETE FROM tmp_User; + END IF; + + SELECT + U.id_user + , U.firstname + , U.surname + , U.email + , U.is_email_verified + , U.id_currency_default + , U.id_region_default + , U.is_included_VAT_default + , U.is_super_user + , UE_T_STORE.can_admin_store AS can_admin_store + , UE_T_USER.can_admin_user AS can_admin_user + FROM tmp_User t_U + INNER JOIN Shop_User U ON t_U.id_user = U.id_user + INNER JOIN ( + SELECT + id_user + , id_permission_required + , can_admin AS can_admin_store + FROM Shop_User_Eval_Temp UE_T_STORE + WHERE 1=1 + AND UE_T_STORE.guid = v_guid + AND UE_T_STORE.id_permission_required = v_id_permission_store_admin + ) UE_T_STORE ON t_U.id_user = UE_T_STORE.id_user + INNER JOIN ( + SELECT + id_user + , id_permission_required + , can_admin AS can_admin_user + FROM Shop_User_Eval_Temp UE_T_USER + WHERE 1=1 + AND UE_T_USER.guid = v_guid + AND UE_T_USER.id_permission_required = v_id_permission_user_admin + ) UE_T_USER ON t_U.id_user = UE_T_USER.id_user + ; + + # Errors + SELECT + /* + t_ME.display_order, + t_ME.guid, + t_ME.id_type, + t_ME.msg, + MET.code, + MET.name, + MET.description + */ + * + FROM tmp_Msg_Error t_ME + INNER JOIN Shop_Msg_Error_Type MET + ON t_ME.id_type = MET.id_type + WHERE guid = v_guid + ; + + + -- Clean up + DROP TEMPORARY TABLE IF EXISTS tmp_User; + DROP TEMPORARY TABLE IF EXISTS tmp_Msg_Error; + + DELETE FROM Shop_User_Eval_Temp + WHERE GUID = v_guid + ; +END // +DELIMITER ; + + +/* + +CALL p_get_many_user ( + NULL # a_id_user + , 0 # a_get_all_user + , 0 # a_get_inactive_user + , 0 # a_get_first_user_only + , NULL # a_ids_user + , '' -- auth0|6582b95c895d09a70ba10fef' # a_ids_user_auth0 +); + +*/ + +USE PARTSLTD_PROD; + /* CALL p_shop_edit_user_basket ( @@ -10321,7 +10590,7 @@ DROP PROCEDURE IF EXISTS p_shop_edit_user_basket; DELIMITER // CREATE PROCEDURE p_shop_edit_user_basket ( - IN a_id_user VARCHAR(200), + IN a_id_user INT, IN a_ids_permutation_basket VARCHAR(4000), IN a_quantities_permutation_basket VARCHAR(4000), IN a_id_permutation_edit INT, @@ -10341,11 +10610,11 @@ BEGIN DECLARE v_n_id_permutation_basket INT; DECLARE v_n_quantity_permutation_basket INT; DECLARE v_row_number INT; - DECLARE v_guid VARCHAR(36); + DECLARE v_guid BINARY(36); # DECLARE v_id_user VARCHAR(100); DECLARE v_id_permission_product INT; DECLARE v_ids_permutation_permission VARCHAR(4000); - DECLARE v_now DATETIME; + DECLARE v_now TIMESTAMP; # DECLARE v_quantity_new INT; DECLARE v_change_set_used BIT; DECLARE v_id_change_set INT; @@ -10380,7 +10649,7 @@ BEGIN DROP TABLE IF EXISTS tmp_Shop_User; CREATE TABLE tmp_Shop_User ( - id_user VARCHAR(200) NOT NULL, + id_user INT NOT NULL, CONSTRAINT FK_tmp_Shop_User_id_user FOREIGN KEY (id_user) REFERENCES Shop_User(id_user), @@ -10437,7 +10706,7 @@ BEGIN CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, id_type INT NOT NULL, # code VARCHAR(50) NOT NULL, # CONSTRAINT chk_tmp_Msg_Error_code CHECK (code IN (SELECT code FROM Shop_Msg_Error_Type)), @@ -11137,7 +11406,7 @@ DROP PROCEDURE IF EXISTS p_shop_save_supplier; DELIMITER // CREATE PROCEDURE p_shop_save_supplier ( IN a_guid VARCHAR(500), - IN a_id_user VARCHAR(200), + IN a_id_user INT, IN a_comment VARCHAR(500), IN a_id_supplier INT, IN a_name_company VARCHAR(256), @@ -11154,7 +11423,7 @@ CREATE PROCEDURE p_shop_save_supplier ( BEGIN DECLARE v_id_error_type_bad_data INT; DECLARE v_id_error_type_no_permission INT; - DECLARE v_guid_permission VARCHAR(36); + DECLARE v_guid_permission BINARY(36); DECLARE v_id_user VARCHAR(100); DECLARE v_id_permission_supplier INT; -- DECLARE v_id_access_level_EDIT INT; @@ -11202,7 +11471,7 @@ BEGIN CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, id_type INT NOT NULL, CONSTRAINT FK_tmp_Msg_Error_id_type FOREIGN KEY (id_type) @@ -11431,7 +11700,7 @@ DROP PROCEDURE IF EXISTS p_shop_get_many_supplier; DELIMITER // CREATE PROCEDURE p_shop_get_many_supplier ( - IN a_id_user VARCHAR(200), + IN a_id_user INT, IN a_get_all_supplier BIT, IN a_get_inactive_supplier BIT, IN a_get_first_supplier_only BIT, @@ -11441,14 +11710,14 @@ BEGIN -- Argument redeclaration -- Variable declaration DECLARE v_has_filter_supplier BIT; - DECLARE v_guid VARCHAR(36); + DECLARE v_guid BINARY(36); # DECLARE v_id_user VARCHAR(100); # DECLARE v_ids_permutation_unavailable VARCHAR(4000); DECLARE v_id_permission_supplier INT; # DECLARE v_ids_product_permission VARCHAR(4000); # DECLARE v_ids_permutation_permission VARCHAR(4000); DECLARE v_id_access_level_view INT; - DECLARE v_now DATETIME; + DECLARE v_now TIMESTAMP; DECLARE v_id_minimum INT; DECLARE v_code_error_data VARCHAR(50); @@ -11492,7 +11761,7 @@ BEGIN CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, id_type INT NOT NULL, CONSTRAINT FK_tmp_Msg_Error_id_type FOREIGN KEY (id_type) @@ -11678,7 +11947,6 @@ insert into shop_product_change_set (comment) id_change_set = (select id_change_set from shop_product_change_set order by id_change_set desc limit 1) where id_product = 1 */ - USE PARTSLTD_PROD; @@ -11691,7 +11959,7 @@ DROP TABLE IF EXISTS tmp_Msg_Error; DELIMITER // CREATE PROCEDURE p_shop_save_supplier_purchase_order ( IN a_guid VARCHAR(500), - IN a_id_user VARCHAR(200), + IN a_id_user INT, IN a_comment VARCHAR(500), IN a_id_order INT, IN a_id_supplier_ordered INT, @@ -11703,7 +11971,7 @@ BEGIN 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 VARCHAR(36); + DECLARE v_guid_permission BINARY(36); -- DECLARE v_id_user VARCHAR(100); DECLARE v_id_permission_supplier_purchase_order INT; DECLARE v_id_access_level_EDIT INT; @@ -11775,7 +12043,7 @@ BEGIN CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, id_type INT NOT NULL, CONSTRAINT FK_tmp_Msg_Error_id_type FOREIGN KEY (id_type) @@ -12243,7 +12511,7 @@ DROP PROCEDURE IF EXISTS p_shop_get_many_supplier_purchase_order; DELIMITER // CREATE PROCEDURE p_shop_get_many_supplier_purchase_order ( - IN a_id_user VARCHAR(200), + IN a_id_user INT, IN a_get_all_supplier BIT, IN a_get_inactive_supplier BIT, IN a_get_first_supplier_only BIT, @@ -12258,8 +12526,8 @@ CREATE PROCEDURE p_shop_get_many_supplier_purchase_order ( IN a_ids_product VARCHAR(4000), IN a_get_inactive_permutation BIT, IN a_ids_permutation VARCHAR(4000), - IN a_date_from DATETIME, - IN a_date_to DATETIME + IN a_date_from TIMESTAMP, + IN a_date_to TIMESTAMP ) BEGIN -- Argument redeclaration @@ -12271,14 +12539,14 @@ BEGIN DECLARE v_has_filter_permutation BIT; DECLARE v_has_filter_date_from BIT; DECLARE v_has_filter_date_to BIT; - DECLARE v_guid VARCHAR(36); + DECLARE v_guid BINARY(36); # DECLARE v_id_user VARCHAR(100); # DECLARE v_ids_permutation_unavailable VARCHAR(4000); DECLARE v_ids_permission_supplier_purchase_order VARCHAR(4000); DECLARE v_ids_product_permission VARCHAR(4000); # DECLARE v_ids_permutation_permission VARCHAR(4000); DECLARE v_id_access_level_view INT; - -- DECLARE v_now DATETIME; + -- DECLARE v_now TIMESTAMP; -- DECLARE v_id_minimum INT; DECLARE v_code_error_data VARCHAR(50); DECLARE v_id_type_error_data INT; @@ -12451,7 +12719,7 @@ BEGIN CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, id_type INT NOT NULL, CONSTRAINT FK_tmp_Msg_Error_id_type FOREIGN KEY (id_type) @@ -13009,7 +13277,7 @@ DROP TABLE IF EXISTS tmp_Msg_Error; DELIMITER // CREATE PROCEDURE p_shop_save_manufacturing_purchase_order ( IN a_guid VARCHAR(500), - IN a_id_user VARCHAR(200), + IN a_id_user INT, IN a_id_order INT, -- IN a_id_supplier_ordered INT, IN a_id_currency_cost INT, @@ -13021,7 +13289,7 @@ BEGIN 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 VARCHAR(36); + 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; @@ -13092,7 +13360,7 @@ BEGIN CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, id_type INT NOT NULL, CONSTRAINT FK_tmp_Msg_Error_id_type FOREIGN KEY (id_type) @@ -13610,7 +13878,7 @@ DROP PROCEDURE IF EXISTS p_shop_get_many_manufacturing_purchase_order; DELIMITER // CREATE PROCEDURE p_shop_get_many_manufacturing_purchase_order ( - IN a_id_user VARCHAR(200), + IN a_id_user INT, IN a_get_all_order BIT, -- IN a_get_inactive_order BIT, IN a_get_first_order_only BIT, @@ -13621,8 +13889,8 @@ CREATE PROCEDURE p_shop_get_many_manufacturing_purchase_order ( IN a_ids_product VARCHAR(4000), IN a_get_inactive_permutation BIT, IN a_ids_permutation VARCHAR(4000), - IN a_date_from DATETIME, - IN a_date_to DATETIME + IN a_date_from TIMESTAMP, + IN a_date_to TIMESTAMP ) BEGIN -- Argument redeclaration @@ -13633,14 +13901,14 @@ BEGIN DECLARE v_has_filter_permutation BIT; DECLARE v_has_filter_date_from BIT; DECLARE v_has_filter_date_to BIT; - DECLARE v_guid VARCHAR(36); + DECLARE v_guid BINARY(36); # DECLARE v_id_user VARCHAR(100); # DECLARE v_ids_permutation_unavailable VARCHAR(4000); DECLARE v_ids_permission_manufacturing_purchase_order VARCHAR(4000); DECLARE v_ids_product_permission VARCHAR(4000); # DECLARE v_ids_permutation_permission VARCHAR(4000); DECLARE v_id_access_level_view INT; - -- DECLARE v_now DATETIME; + -- DECLARE v_now TIMESTAMP; -- DECLARE v_id_minimum INT; DECLARE v_code_error_data VARCHAR(50); DECLARE v_id_type_error_data INT; @@ -13791,7 +14059,7 @@ BEGIN CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, id_type INT NOT NULL, CONSTRAINT FK_tmp_Msg_Error_id_type FOREIGN KEY (id_type) @@ -14268,7 +14536,7 @@ DROP PROCEDURE IF EXISTS p_shop_save_customer; DELIMITER // CREATE PROCEDURE p_shop_save_customer ( IN a_guid VARCHAR(500), - IN a_id_user VARCHAR(200), + IN a_id_user INT, IN a_comment VARCHAR(500), IN a_id_customer INT, IN a_name_company VARCHAR(256), @@ -14283,7 +14551,7 @@ CREATE PROCEDURE p_shop_save_customer ( BEGIN DECLARE v_id_error_type_bad_data INT; DECLARE v_id_error_type_no_permission INT; - DECLARE v_guid_permission VARCHAR(36); + DECLARE v_guid_permission BINARY(36); DECLARE v_id_permission_customer INT; DECLARE v_id_access_level_EDIT INT; DECLARE v_has_permission BIT; @@ -14329,7 +14597,7 @@ BEGIN CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, id_type INT NOT NULL, CONSTRAINT FK_tmp_Msg_Error_id_type FOREIGN KEY (id_type) @@ -14579,7 +14847,7 @@ DROP PROCEDURE IF EXISTS p_shop_get_many_customer; DELIMITER // CREATE PROCEDURE p_shop_get_many_customer ( - IN a_id_user VARCHAR(200), + IN a_id_user INT, IN a_get_all_customer BIT, IN a_get_inactive_customer BIT, IN a_get_first_customer_only BIT, @@ -14591,14 +14859,14 @@ BEGIN DECLARE v_id_error_type_bad_data INT; DECLARE v_code_error_type_bad_data VARCHAR(50); DECLARE v_has_filter_customer BIT; - DECLARE v_guid VARCHAR(36); + DECLARE v_guid BINARY(36); # DECLARE v_id_user VARCHAR(100); # DECLARE v_ids_permutation_unavailable VARCHAR(4000); DECLARE v_id_permission_customer INT; # DECLARE v_ids_product_permission VARCHAR(4000); # DECLARE v_ids_permutation_permission VARCHAR(4000); DECLARE v_id_access_level_view INT; - DECLARE v_now DATETIME; + DECLARE v_now TIMESTAMP; DECLARE v_id_minimum INT; SET v_code_error_type_bad_data = 'BAD_DATA'; @@ -14649,7 +14917,7 @@ BEGIN CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, id_type INT NOT NULL, CONSTRAINT FK_tmp_Msg_Error_id_type FOREIGN KEY (id_type) @@ -14840,7 +15108,7 @@ DROP TABLE IF EXISTS tmp_Msg_Error; DELIMITER // CREATE PROCEDURE p_shop_save_customer_sales_order ( IN a_guid VARCHAR(500), - IN a_id_user VARCHAR(200), + IN a_id_user INT, IN a_comment VARCHAR(500), IN a_id_order INT, IN a_id_customer INT, @@ -14852,7 +15120,7 @@ BEGIN 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 VARCHAR(36); + DECLARE v_guid_permission BINARY(36); -- DECLARE v_id_user VARCHAR(100); DECLARE v_id_permission_Customer_Sales_order INT; DECLARE v_id_access_level_EDIT INT; @@ -14922,7 +15190,7 @@ BEGIN CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, id_type INT NOT NULL, CONSTRAINT FK_tmp_Msg_Error_id_type FOREIGN KEY (id_type) @@ -15393,7 +15661,7 @@ DROP PROCEDURE IF EXISTS p_shop_get_many_customer_sales_order; DELIMITER // CREATE PROCEDURE p_shop_get_many_customer_sales_order ( - IN a_id_user VARCHAR(200), + IN a_id_user INT, IN a_get_all_customer BIT, IN a_get_inactive_customer BIT, IN a_get_first_customer_only BIT, @@ -15408,8 +15676,8 @@ CREATE PROCEDURE p_shop_get_many_customer_sales_order ( IN a_ids_product VARCHAR(4000), IN a_get_inactive_permutation BIT, IN a_ids_permutation VARCHAR(4000), - IN a_date_from DATETIME, - IN a_date_to DATETIME + IN a_date_from TIMESTAMP, + IN a_date_to TIMESTAMP ) BEGIN -- Argument redeclaration @@ -15421,14 +15689,14 @@ BEGIN DECLARE v_has_filter_permutation BIT; DECLARE v_has_filter_date_from BIT; DECLARE v_has_filter_date_to BIT; - DECLARE v_guid VARCHAR(36); + DECLARE v_guid BINARY(36); # DECLARE v_id_user VARCHAR(100); # DECLARE v_ids_permutation_unavailable VARCHAR(4000); DECLARE v_ids_permission_customer_purchase_order VARCHAR(4000); DECLARE v_ids_product_permission VARCHAR(4000); # DECLARE v_ids_permutation_permission VARCHAR(4000); DECLARE v_id_access_level_view INT; - -- DECLARE v_now DATETIME; + -- DECLARE v_now TIMESTAMP; -- DECLARE v_id_minimum INT; DECLARE v_code_error_data VARCHAR(50); DECLARE v_id_type_error_data INT; @@ -15609,7 +15877,7 @@ BEGIN CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, id_type INT NOT NULL, CONSTRAINT FK_tmp_Msg_Error_id_type FOREIGN KEY (id_type) @@ -16704,6 +16972,7 @@ VALUES (1, 'HOME', 'Home Page', 2, 1), (2, 'STORE_PRODUCT', 'Store Product Page', 3, 1), (3, 'STORE_USER', 'Store User Account Page', 4, 2), + (10, 'STORE_USER_ADMIN', 'Store User Admin Page', 4, 3), (4, 'STORE_ADMIN', 'Store Admin Page', 1, 3), (5, 'STORE_SUPPLIER', 'Store Supplier Page', 4, 2), (6, 'STORE_SUPPLIER_PURCHASE_ORDER', 'Store Supplier Purchase Order Page', 4, 2), @@ -16743,15 +17012,16 @@ VALUES # Users INSERT INTO Shop_User ( - id_user, - name, - email, - # email_verified, - is_super_user + id_user_auth0 + , firstname + , surname + , email + # email_verified + , is_super_user ) VALUES - ('auth0|6582b95c895d09a70ba10fef', 'Teddy', 'edward.middletonsmith@gmail.com', 1), - ('parts_guest', 'Guest', '', 0) + ('auth0|6582b95c895d09a70ba10fef', 'Teddy', 'Middleton-Smith', 'edward.middletonsmith@gmail.com', 1), + ('parts_guest', 'Guest', '', '', 0) ; # User Role link @@ -16759,14 +17029,14 @@ INSERT INTO Shop_User_Role_Link ( id_user, id_role ) VALUES - ('auth0|6582b95c895d09a70ba10fef', 1) + (1, 1) ; # Addresses INSERT INTO Shop_Address ( id_user, id_region, name_full, phone_number, postcode, address_line_1, address_line_2, city, county ) -SELECT U.id_user, 1, U.name, '07375 571430', 'CV22 6DN', '53 Alfred Green Close', '', 'Rugby', 'Warwickshire' +SELECT U.id_user, 1, CONCAT(U.firstname, ' ', U.surname), '07375 571430', 'CV22 6DN', '53 Alfred Green Close', '', 'Rugby', 'Warwickshire' FROM Shop_User U ; @@ -16778,7 +17048,7 @@ INSERT INTO Shop_User_Basket ( quantity ) VALUES - ('auth0|6582b95c895d09a70ba10fef', 1, 1, 69) + (1, 1, 1, 69) ; # User Order Status @@ -16796,8 +17066,8 @@ INSERT INTO Shop_User_Order ( id_user, value_total, id_order_status, id_checkout_session, id_currency ) VALUES - ('auth0|6582b95c895d09a70ba10fef', 25, 1, 'noods', 1), - ('auth0|6582b95c895d09a70ba10fef', 25, 1, 'noods', 1) + (1, 25, 1, 'noods', 1), + (1, 25, 1, 'noods', 1) ; # User Order Product Link @@ -16961,7 +17231,7 @@ SELECT * FROM Shop_Storage_Location_Branch_Audit; # Currencies SELECT * FROM Shop_Currency; -SELECT * FROM Shop_CurrencyAudit; +SELECT * FROM Shop_Currency_Audit; # Taxes and Surcharges SELECT * FROM Shop_Tax_Or_Surcharge; @@ -17139,8 +17409,8 @@ FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'PARTS' - -- AND TABLE_NAME = 'your_table_name'; -SELECT URL.id_link, + -- AND TABLE_NAME = 'your_table_name' +;SELECT URL.id_link, URL.id_user, U.name AS name, URL.id_role, diff --git a/static/MySQL/1000_tbl_Shop_Product_Change_Set.sql b/static/MySQL/1000_tbl_Shop_Product_Change_Set.sql index eb70fc2e..a8bd4de0 100644 --- a/static/MySQL/1000_tbl_Shop_Product_Change_Set.sql +++ b/static/MySQL/1000_tbl_Shop_Product_Change_Set.sql @@ -8,6 +8,6 @@ SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning CREATE TABLE Shop_Product_Change_Set ( id_change_set INT NOT NULL AUTO_INCREMENT PRIMARY KEY, comment VARCHAR(500), - updated_last_on DATETIME, + updated_last_on TIMESTAMP, updated_last_by VARCHAR(100) ); \ No newline at end of file diff --git a/static/MySQL/1001_tbl_Shop_User_Change_Set.sql b/static/MySQL/1001_tbl_Shop_User_Change_Set.sql index d0e320b8..70e1b5cd 100644 --- a/static/MySQL/1001_tbl_Shop_User_Change_Set.sql +++ b/static/MySQL/1001_tbl_Shop_User_Change_Set.sql @@ -8,6 +8,6 @@ SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning CREATE TABLE IF NOT EXISTS Shop_User_Change_Set ( id_change_set INT NOT NULL AUTO_INCREMENT PRIMARY KEY, comment VARCHAR(500), - updated_last_on DATETIME, + updated_last_on TIMESTAMP, updated_last_by VARCHAR(100) ); \ No newline at end of file diff --git a/static/MySQL/1002_tbl_Shop_Sales_And_Purchasing_Change_Set.sql b/static/MySQL/1002_tbl_Shop_Sales_And_Purchasing_Change_Set.sql index 24113b50..2cfec702 100644 --- a/static/MySQL/1002_tbl_Shop_Sales_And_Purchasing_Change_Set.sql +++ b/static/MySQL/1002_tbl_Shop_Sales_And_Purchasing_Change_Set.sql @@ -8,6 +8,6 @@ SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning CREATE TABLE Shop_Sales_And_Purchasing_Change_Set ( id_change_set INT NOT NULL AUTO_INCREMENT PRIMARY KEY, comment VARCHAR(500), - updated_last_on DATETIME, + updated_last_on TIMESTAMP, updated_last_by VARCHAR(100) ); \ No newline at end of file diff --git a/static/MySQL/1003_tbl_Shop_Access_Level.sql b/static/MySQL/1003_tbl_Shop_Access_Level.sql index 411c8d89..cb0265cf 100644 --- a/static/MySQL/1003_tbl_Shop_Access_Level.sql +++ b/static/MySQL/1003_tbl_Shop_Access_Level.sql @@ -12,7 +12,7 @@ CREATE TABLE IF NOT EXISTS Shop_Access_Level ( priority INT NOT NULL, active BIT NOT NULL DEFAULT 1, display_order INT NOT NULL, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Access_Level_id_change_set diff --git a/static/MySQL/1010_tbl_File_Type.sql b/static/MySQL/1010_tbl_File_Type.sql index 1a5f51ee..0d6bd239 100644 --- a/static/MySQL/1010_tbl_File_Type.sql +++ b/static/MySQL/1010_tbl_File_Type.sql @@ -10,8 +10,8 @@ CREATE TABLE IF NOT EXISTS File_Type ( code VARCHAR(50), name VARCHAR(100), extension VARCHAR(50), - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), - updated_last_on DATETIME, + updated_last_on TIMESTAMP, updated_last_by VARCHAR(100) ); diff --git a/static/MySQL/1011_tbl_File_Type_Audit.sql b/static/MySQL/1011_tbl_File_Type_Audit.sql index 09069089..a79e514c 100644 --- a/static/MySQL/1011_tbl_File_Type_Audit.sql +++ b/static/MySQL/1011_tbl_File_Type_Audit.sql @@ -15,8 +15,8 @@ CREATE TABLE IF NOT EXISTS File_Type_Audit ( name_field VARCHAR(50), value_prev VARCHAR(500), value_new VARCHAR(500), - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), - updated_last_on DATETIME, + updated_last_on TIMESTAMP, updated_last_by VARCHAR(100) ); \ No newline at end of file diff --git a/static/MySQL/1012_tbl_Shop_General.sql b/static/MySQL/1012_tbl_Shop_General.sql index 1cce4049..642f50f9 100644 --- a/static/MySQL/1012_tbl_Shop_General.sql +++ b/static/MySQL/1012_tbl_Shop_General.sql @@ -8,7 +8,7 @@ SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning CREATE TABLE IF NOT EXISTS Shop_General ( id_general INT NOT NULL AUTO_INCREMENT PRIMARY KEY, quantity_max FLOAT, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT CHK_Shop_General_id_change_set diff --git a/static/MySQL/1014_tbl_Shop_Image_Type.sql b/static/MySQL/1014_tbl_Shop_Image_Type.sql index a78da215..831b9971 100644 --- a/static/MySQL/1014_tbl_Shop_Image_Type.sql +++ b/static/MySQL/1014_tbl_Shop_Image_Type.sql @@ -18,7 +18,7 @@ CREATE TABLE IF NOT EXISTS Shop_Image_Type ( name_plural VARCHAR(256), active BIT NOT NULL DEFAULT 1, display_order INT NOT NULL, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Image_Type_id_change_set diff --git a/static/MySQL/1100_tbl_Shop_Region.sql b/static/MySQL/1100_tbl_Shop_Region.sql index b6ed6b03..5aba627a 100644 --- a/static/MySQL/1100_tbl_Shop_Region.sql +++ b/static/MySQL/1100_tbl_Shop_Region.sql @@ -11,7 +11,7 @@ CREATE TABLE IF NOT EXISTS Shop_Region ( name VARCHAR(200) NOT NULL, active BIT NOT NULL DEFAULT 1, display_order INT NOT NULL, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Region_id_change_set diff --git a/static/MySQL/1102_tbl_Shop_Region_Temp.sql b/static/MySQL/1102_tbl_Shop_Region_Temp.sql index d9e8e9dc..7f1a6ae4 100644 --- a/static/MySQL/1102_tbl_Shop_Region_Temp.sql +++ b/static/MySQL/1102_tbl_Shop_Region_Temp.sql @@ -11,7 +11,7 @@ CREATE TABLE IF NOT EXISTS Shop_Region_Temp ( name VARCHAR(200) NOT NULL, active BIT NOT NULL DEFAULT 1, display_order INT NOT NULL, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Region_Temp_id_change_set diff --git a/static/MySQL/1103_tbl_Shop_Region_Branch.sql b/static/MySQL/1103_tbl_Shop_Region_Branch.sql index a5a5e1a7..05fdee85 100644 --- a/static/MySQL/1103_tbl_Shop_Region_Branch.sql +++ b/static/MySQL/1103_tbl_Shop_Region_Branch.sql @@ -20,7 +20,7 @@ CREATE TABLE IF NOT EXISTS Shop_Region_Branch ( -- depth INT NOT NULL, active BIT NOT NULL DEFAULT 1, display_order INT NOT NULL, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Region_Branch_id_change_set diff --git a/static/MySQL/1106_tbl_Shop_Plant.sql b/static/MySQL/1106_tbl_Shop_Plant.sql index 341fda5f..b44b0f0d 100644 --- a/static/MySQL/1106_tbl_Shop_Plant.sql +++ b/static/MySQL/1106_tbl_Shop_Plant.sql @@ -12,7 +12,7 @@ CREATE TABLE IF NOT EXISTS Shop_Plant ( id_address INT NOT NULL, id_user_manager INT NOT NULL, active BIT NOT NULL DEFAULT 1, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Plant_id_change_set diff --git a/static/MySQL/1109_tbl_Shop_Storage_Location.sql b/static/MySQL/1109_tbl_Shop_Storage_Location.sql index a361cdc4..747bde4a 100644 --- a/static/MySQL/1109_tbl_Shop_Storage_Location.sql +++ b/static/MySQL/1109_tbl_Shop_Storage_Location.sql @@ -14,7 +14,7 @@ CREATE TABLE IF NOT EXISTS Shop_Storage_Location ( code VARCHAR(50) NOT NULL, name VARCHAR(500) NOT NULL, active BIT NOT NULL DEFAULT 1, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Storage_Location_id_change_set diff --git a/static/MySQL/1112_tbl_Shop_Storage_Location_Branch.sql b/static/MySQL/1112_tbl_Shop_Storage_Location_Branch.sql index 463e54cb..2679ca79 100644 --- a/static/MySQL/1112_tbl_Shop_Storage_Location_Branch.sql +++ b/static/MySQL/1112_tbl_Shop_Storage_Location_Branch.sql @@ -20,7 +20,7 @@ CREATE TABLE IF NOT EXISTS Shop_Storage_Location_Branch ( -- depth INT NOT NULL, active BIT NOT NULL DEFAULT 1, display_order INT NOT NULL, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Storage_Location_Branch_id_change_set diff --git a/static/MySQL/1115_tbl_Shop_Currency.sql b/static/MySQL/1115_tbl_Shop_Currency.sql index 2a3a7294..c3900bd5 100644 --- a/static/MySQL/1115_tbl_Shop_Currency.sql +++ b/static/MySQL/1115_tbl_Shop_Currency.sql @@ -13,7 +13,7 @@ CREATE TABLE IF NOT EXISTS Shop_Currency ( factor_from_GBP FLOAT NOT NULL, active BIT NOT NULL DEFAULT 1, display_order INT NOT NULL, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Currency_id_change_set diff --git a/static/MySQL/1118_tbl_Shop_Tax_Or_Surcharge.sql b/static/MySQL/1118_tbl_Shop_Tax_Or_Surcharge.sql index 9f3f891c..130c1e21 100644 --- a/static/MySQL/1118_tbl_Shop_Tax_Or_Surcharge.sql +++ b/static/MySQL/1118_tbl_Shop_Tax_Or_Surcharge.sql @@ -29,7 +29,7 @@ CREATE TABLE Shop_Tax_Or_Surcharge ( quantity_max FLOAT NOT NULL, active BIT NOT NULL DEFAULT 1, display_order INT NOT NULL, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Tax_Or_Surcharge_id_change_set diff --git a/static/MySQL/1121_tbl_Shop_Unit_Measurement.sql b/static/MySQL/1121_tbl_Shop_Unit_Measurement.sql index ec9698cb..b7b784f2 100644 --- a/static/MySQL/1121_tbl_Shop_Unit_Measurement.sql +++ b/static/MySQL/1121_tbl_Shop_Unit_Measurement.sql @@ -16,7 +16,7 @@ CREATE TABLE IF NOT EXISTS Shop_Unit_Measurement ( is_unit_of_time BIT NOT NULL DEFAULT 0, is_unit_of_volume BIT NOT NULL DEFAULT 0, active BIT NOT NULL DEFAULT 1, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Unit_Measurement_id_change_set diff --git a/static/MySQL/1124_tbl_Shop_Unit_Measurement_Conversion.sql b/static/MySQL/1124_tbl_Shop_Unit_Measurement_Conversion.sql index bb65670a..b9d53b9a 100644 --- a/static/MySQL/1124_tbl_Shop_Unit_Measurement_Conversion.sql +++ b/static/MySQL/1124_tbl_Shop_Unit_Measurement_Conversion.sql @@ -13,7 +13,7 @@ CREATE TABLE IF NOT EXISTS Shop_Unit_Measurement_Conversion ( multiplier_unit_base FLOAT NOT NULL, increment_unit_base FLOAT NOT NULL, active BIT NOT NULL DEFAULT 1, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Unit_Measurement_Conversion_id_change_set diff --git a/static/MySQL/1200_tbl_Shop_Category.sql b/static/MySQL/1200_tbl_Shop_Category.sql index 8ff92dc5..8fcca71f 100644 --- a/static/MySQL/1200_tbl_Shop_Category.sql +++ b/static/MySQL/1200_tbl_Shop_Category.sql @@ -12,7 +12,7 @@ CREATE TABLE IF NOT EXISTS Shop_Category ( description VARCHAR(4000), active BIT NOT NULL DEFAULT 1, display_order INT NOT NULL, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Category_id_change_set diff --git a/static/MySQL/1203_tbl_Shop_Product.sql b/static/MySQL/1203_tbl_Shop_Product.sql index 9a28fef2..1a56f455 100644 --- a/static/MySQL/1203_tbl_Shop_Product.sql +++ b/static/MySQL/1203_tbl_Shop_Product.sql @@ -39,7 +39,7 @@ CREATE TABLE IF NOT EXISTS Shop_Product ( # id_stripe_price VARCHAR(100) NOT NULL, active BIT NOT NULL DEFAULT 1, display_order INT NOT NULL, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Product_id_change_set diff --git a/static/MySQL/1206_tbl_Shop_Product_Permutation.sql b/static/MySQL/1206_tbl_Shop_Product_Permutation.sql index 3cc5e1be..540dd9c0 100644 --- a/static/MySQL/1206_tbl_Shop_Product_Permutation.sql +++ b/static/MySQL/1206_tbl_Shop_Product_Permutation.sql @@ -46,7 +46,7 @@ CREATE TABLE IF NOT EXISTS Shop_Product_Permutation ( count_interval_expiration_unsealed INT, active BIT NOT NULL DEFAULT 1, display_order INT NOT NULL, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Product_Permutation_id_change_set diff --git a/static/MySQL/1208_tbl_Shop_Product_Permutation_Temp.sql b/static/MySQL/1208_tbl_Shop_Product_Permutation_Temp.sql index 021ebff4..7790138c 100644 --- a/static/MySQL/1208_tbl_Shop_Product_Permutation_Temp.sql +++ b/static/MySQL/1208_tbl_Shop_Product_Permutation_Temp.sql @@ -36,7 +36,7 @@ CREATE TABLE IF NOT EXISTS Shop_Product_Permutation_Temp ( count_interval_expiration_unsealed INT, active BIT NOT NULL DEFAULT 1, display_order INT NOT NULL, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), - guid VARCHAR(36) + guid BINARY(36) ); diff --git a/static/MySQL/1209_tbl_Shop_Variation_Type.sql b/static/MySQL/1209_tbl_Shop_Variation_Type.sql index 9d15318d..c3a5861c 100644 --- a/static/MySQL/1209_tbl_Shop_Variation_Type.sql +++ b/static/MySQL/1209_tbl_Shop_Variation_Type.sql @@ -12,7 +12,7 @@ CREATE TABLE IF NOT EXISTS Shop_Variation_Type ( name_plural VARCHAR(256), active BIT NOT NULL DEFAULT 1, display_order INT NOT NULL, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Variation_Type_id_change_set diff --git a/static/MySQL/1212_tbl_Shop_Variation.sql b/static/MySQL/1212_tbl_Shop_Variation.sql index 2fde7979..eaa46ee9 100644 --- a/static/MySQL/1212_tbl_Shop_Variation.sql +++ b/static/MySQL/1212_tbl_Shop_Variation.sql @@ -16,7 +16,7 @@ CREATE TABLE Shop_Variation ( name VARCHAR(255), active BIT NOT NULL DEFAULT 1, display_order INT NOT NULL, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Variation_id_change_set diff --git a/static/MySQL/1215_tbl_Shop_Product_Permutation_Variation_Link.sql b/static/MySQL/1215_tbl_Shop_Product_Permutation_Variation_Link.sql index 2903ff13..ba8ce6d1 100644 --- a/static/MySQL/1215_tbl_Shop_Product_Permutation_Variation_Link.sql +++ b/static/MySQL/1215_tbl_Shop_Product_Permutation_Variation_Link.sql @@ -19,7 +19,7 @@ CREATE TABLE IF NOT EXISTS Shop_Product_Permutation_Variation_Link ( ON UPDATE RESTRICT, active BIT NOT NULL DEFAULT 1, display_order INT NOT NULL, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Product_Permutation_Variation_Link_id_change_set diff --git a/static/MySQL/1218_tbl_Shop_Stock_Item.sql b/static/MySQL/1218_tbl_Shop_Stock_Item.sql index 1142a068..cafa24a3 100644 --- a/static/MySQL/1218_tbl_Shop_Stock_Item.sql +++ b/static/MySQL/1218_tbl_Shop_Stock_Item.sql @@ -11,8 +11,8 @@ CREATE TABLE IF NOT EXISTS Shop_Stock_Item ( 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, + date_purchased TIMESTAMP NOT NULL, + date_received TIMESTAMP NULL, id_location_storage INT NOT NULL, CONSTRAINT FK_Shop_Stock_Item_id_location_storage FOREIGN KEY (id_location_storage) @@ -24,12 +24,12 @@ CREATE TABLE IF NOT EXISTS Shop_Stock_Item ( cost_local_VAT_incl FLOAT NOT NULL, cost_local_VAT_excl FLOAT NOT NULL, is_sealed BIT NOT NULL DEFAULT 1, - date_unsealed DATETIME NULL, - date_expiration DATETIME NOT NULL, + date_unsealed TIMESTAMP NULL, + date_expiration TIMESTAMP NOT NULL, is_consumed BIT NOT NULL DEFAULT 0, - date_consumed DATETIME NULL, + date_consumed TIMESTAMP NULL, active BIT NOT NULL DEFAULT 1, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Stock_Item_id_change_set diff --git a/static/MySQL/1220_tbl_Shop_Stock_Item_Temp.sql b/static/MySQL/1220_tbl_Shop_Stock_Item_Temp.sql index 8a3be8a1..c4f4443c 100644 --- a/static/MySQL/1220_tbl_Shop_Stock_Item_Temp.sql +++ b/static/MySQL/1220_tbl_Shop_Stock_Item_Temp.sql @@ -8,15 +8,15 @@ SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning CREATE TABLE IF NOT EXISTS Shop_Stock_Item_Temp ( id_stock INT NOT NULL PRIMARY KEY, id_permutation INT NOT NULL, - date_purchased DATETIME NOT NULL, + date_purchased TIMESTAMP NOT NULL, id_location_storage INT NOT NULL, id_currency INT NOT NULL, cost_local_VAT_incl FLOAT NOT NULL, cost_local_VAT_excl FLOAT NOT NULL, is_sealed BIT NOT NULL DEFAULT 1, - date_unsealed DATETIME NULL, - date_expiration DATETIME NULL, + date_unsealed TIMESTAMP NULL, + date_expiration TIMESTAMP NULL, is_consumed BIT NOT NULL DEFAULT 0, - date_consumed DATETIME NULL, + date_consumed TIMESTAMP NULL, active BIT NOT NULL DEFAULT 1 ); diff --git a/static/MySQL/1221_tbl_Shop_Product_Price.sql b/static/MySQL/1221_tbl_Shop_Product_Price.sql index e3f87b1e..0eed0e44 100644 --- a/static/MySQL/1221_tbl_Shop_Product_Price.sql +++ b/static/MySQL/1221_tbl_Shop_Product_Price.sql @@ -23,7 +23,7 @@ CREATE TABLE IF NOT EXISTS Shop_Product_Price ( price_local_VAT_excl FLOAT NULL, id_stripe_price VARCHAR(200), active BIT NOT NULL DEFAULT 1, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Product_Price_id_change_set diff --git a/static/MySQL/1224_tbl_Shop_Product_Image.sql b/static/MySQL/1224_tbl_Shop_Product_Image.sql index 4ebd6189..9d6b7dba 100644 --- a/static/MySQL/1224_tbl_Shop_Product_Image.sql +++ b/static/MySQL/1224_tbl_Shop_Product_Image.sql @@ -18,7 +18,7 @@ CREATE TABLE IF NOT EXISTS Shop_Product_Image ( url VARCHAR(255), active BIT NOT NULL DEFAULT 1, display_order INT NOT NULL, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Product_Image_id_change_set diff --git a/static/MySQL/1227_tbl_Shop_Delivery_Option.sql b/static/MySQL/1227_tbl_Shop_Delivery_Option.sql index d16f0860..4b2b6dca 100644 --- a/static/MySQL/1227_tbl_Shop_Delivery_Option.sql +++ b/static/MySQL/1227_tbl_Shop_Delivery_Option.sql @@ -16,7 +16,7 @@ CREATE TABLE IF NOT EXISTS Shop_Delivery_Option ( quantity_max INT NOT NULL, active BIT NOT NULL DEFAULT 1, display_order INT NOT NULL, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Delivery_Option_Type_id_change_set diff --git a/static/MySQL/1230_tbl_Shop_Product_Delivery_Option_Link.sql b/static/MySQL/1230_tbl_Shop_Product_Delivery_Option_Link.sql index 260126e6..df22d282 100644 --- a/static/MySQL/1230_tbl_Shop_Product_Delivery_Option_Link.sql +++ b/static/MySQL/1230_tbl_Shop_Product_Delivery_Option_Link.sql @@ -35,7 +35,7 @@ CREATE TABLE IF NOT EXISTS Shop_Product_Delivery_Option_Link ( price_local FLOAT NOT NULL, active BIT NOT NULL DEFAULT 1, display_order INT NOT NULL, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Product_Delivery_Option_Link_id_change_set diff --git a/static/MySQL/1233_tbl_Shop_Discount.sql b/static/MySQL/1233_tbl_Shop_Discount.sql index e81e4ff7..400fa345 100644 --- a/static/MySQL/1233_tbl_Shop_Discount.sql +++ b/static/MySQL/1233_tbl_Shop_Discount.sql @@ -35,11 +35,11 @@ CREATE TABLE Shop_Discount ( apply_multiplier_first BIT DEFAULT 1, quantity_min FLOAT NOT NULL DEFAULT 0, quantity_max FLOAT NOT NULL, - date_start DATETIME NOT NULL, - date_end DATETIME NOT NULL, + date_start TIMESTAMP NOT NULL, + date_end TIMESTAMP NOT NULL, active BIT NOT NULL DEFAULT 1, display_order INT NOT NULL, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Discount_id_change_set diff --git a/static/MySQL/1236_tbl_Shop_Discount_Region_Currency_Link.sql b/static/MySQL/1236_tbl_Shop_Discount_Region_Currency_Link.sql index 1b2cbfaa..05d87ad4 100644 --- a/static/MySQL/1236_tbl_Shop_Discount_Region_Currency_Link.sql +++ b/static/MySQL/1236_tbl_Shop_Discount_Region_Currency_Link.sql @@ -23,7 +23,7 @@ CREATE TABLE IF NOT EXISTS Shop_Discount_Region_Currency_Link ( REFERENCES Shop_Currency(id_currency) ON UPDATE RESTRICT, active BIT NOT NULL DEFAULT 1, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Discount_Region_Currency_Link_id_change_set diff --git a/static/MySQL/1236_tbl_Shop_Product_Currency_Region_Link.sql b/static/MySQL/1236_tbl_Shop_Product_Currency_Region_Link.sql index d6a4555f..45070f3a 100644 --- a/static/MySQL/1236_tbl_Shop_Product_Currency_Region_Link.sql +++ b/static/MySQL/1236_tbl_Shop_Product_Currency_Region_Link.sql @@ -31,7 +31,7 @@ CREATE TABLE IF NOT EXISTS Shop_Product_Currency_Region_Link ( price_local_VAT_excl FLOAT NULL, id_stripe_price VARCHAR(200), active BIT NOT NULL DEFAULT 1, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Product_Currency_Region_Link_id_change_set diff --git a/static/MySQL/1300_tbl_Shop_Permission_Group.sql b/static/MySQL/1300_tbl_Shop_Permission_Group.sql index 578de2dc..eebb5cb0 100644 --- a/static/MySQL/1300_tbl_Shop_Permission_Group.sql +++ b/static/MySQL/1300_tbl_Shop_Permission_Group.sql @@ -11,7 +11,7 @@ CREATE TABLE IF NOT EXISTS Shop_Permission_Group ( name VARCHAR(255), active BIT NOT NULL DEFAULT 1, display_order INT NOT NULL, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Permission_Group_id_change_set diff --git a/static/MySQL/1303_tbl_Shop_Permission.sql b/static/MySQL/1303_tbl_Shop_Permission.sql index 53623cf5..0aff1c1a 100644 --- a/static/MySQL/1303_tbl_Shop_Permission.sql +++ b/static/MySQL/1303_tbl_Shop_Permission.sql @@ -20,7 +20,7 @@ CREATE TABLE IF NOT EXISTS Shop_Permission ( REFERENCES Shop_Access_Level(id_access_level), active BIT NOT NULL DEFAULT 1, display_order INT NOT NULL, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Permission_id_change_set diff --git a/static/MySQL/1306_tbl_Shop_Role.sql b/static/MySQL/1306_tbl_Shop_Role.sql index 3bc2d350..32699fc5 100644 --- a/static/MySQL/1306_tbl_Shop_Role.sql +++ b/static/MySQL/1306_tbl_Shop_Role.sql @@ -11,7 +11,7 @@ CREATE TABLE IF NOT EXISTS Shop_Role ( name VARCHAR(255), active BIT NOT NULL DEFAULT 1, display_order INT NOT NULL, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Role_id_change_set diff --git a/static/MySQL/1309_tbl_Shop_Role_Permission_Link.sql b/static/MySQL/1309_tbl_Shop_Role_Permission_Link.sql index 82b21b07..416af52d 100644 --- a/static/MySQL/1309_tbl_Shop_Role_Permission_Link.sql +++ b/static/MySQL/1309_tbl_Shop_Role_Permission_Link.sql @@ -22,7 +22,7 @@ CREATE TABLE IF NOT EXISTS Shop_Role_Permission_Link ( FOREIGN KEY (id_access_level) REFERENCES Shop_Access_Level(id_access_level), active BIT NOT NULL DEFAULT 1, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Role_Permission_Link_id_change_set diff --git a/static/MySQL/1312_tbl_Shop_User.sql b/static/MySQL/1312_tbl_Shop_User.sql index b5fdef4a..954b89fb 100644 --- a/static/MySQL/1312_tbl_Shop_User.sql +++ b/static/MySQL/1312_tbl_Shop_User.sql @@ -6,13 +6,18 @@ USE PARTSLTD_PROD; SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_User'; CREATE TABLE IF NOT EXISTS Shop_User ( - id_user VARCHAR(200) NOT NULL PRIMARY KEY, - name VARCHAR(255) NOT NULL, + id_user INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + id_user_auth0 VARCHAR(200) NOT NULL, + firstname VARCHAR(255) NOT NULL, + surname VARCHAR(255) NOT NULL, email VARCHAR(254) NOT NULL, - email_verified BIT NOT NULL DEFAULT 0, + is_email_verified BIT NOT NULL DEFAULT 0, is_super_user BIT NOT NULL DEFAULT 0, + id_currency_default INT NULL, + id_region_default INT NULL, + is_included_VAT_default BIT NOT NULL DEFAULT 1, active BIT NOT NULL DEFAULT 1, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_User_id_change_set diff --git a/static/MySQL/1313_tbl_Shop_User_Audit.sql b/static/MySQL/1313_tbl_Shop_User_Audit.sql index d3640a39..a8a8a242 100644 --- a/static/MySQL/1313_tbl_Shop_User_Audit.sql +++ b/static/MySQL/1313_tbl_Shop_User_Audit.sql @@ -7,7 +7,7 @@ SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning CREATE TABLE IF NOT EXISTS Shop_User_Audit ( id_audit INT NOT NULL AUTO_INCREMENT PRIMARY KEY, - id_user VARCHAR(200) NOT NULL, + id_user INT NOT NULL, CONSTRAINT FK_Shop_User_Audit_id_user FOREIGN KEY (id_user) REFERENCES Shop_User(id_user) diff --git a/static/MySQL/1315_tbl_Shop_User_Role_Link.sql b/static/MySQL/1315_tbl_Shop_User_Role_Link.sql index c05af174..f4400020 100644 --- a/static/MySQL/1315_tbl_Shop_User_Role_Link.sql +++ b/static/MySQL/1315_tbl_Shop_User_Role_Link.sql @@ -7,7 +7,7 @@ SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning CREATE TABLE IF NOT EXISTS Shop_User_Role_Link ( id_link INT NOT NULL AUTO_INCREMENT PRIMARY KEY, - id_user VARCHAR(200) NOT NULL, + id_user INT NOT NULL, CONSTRAINT FK_Shop_User_Role_Link_id_user FOREIGN KEY (id_user) REFERENCES Shop_User(id_user) @@ -17,7 +17,7 @@ CREATE TABLE IF NOT EXISTS Shop_User_Role_Link ( FOREIGN KEY (id_role) REFERENCES Shop_Role(id_role), active BIT NOT NULL DEFAULT 1, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_User_Role_Link_id_change_set diff --git a/static/MySQL/1318_tbl_Shop_Address.sql b/static/MySQL/1318_tbl_Shop_Address.sql index 882a196b..6f1e3a26 100644 --- a/static/MySQL/1318_tbl_Shop_Address.sql +++ b/static/MySQL/1318_tbl_Shop_Address.sql @@ -7,7 +7,7 @@ SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning CREATE TABLE Shop_Address ( id_address INT NOT NULL AUTO_INCREMENT PRIMARY KEY, - id_user VARCHAR(200) NOT NULL, + id_user INT NOT NULL, CONSTRAINT FK_Shop_Address_id_user FOREIGN KEY (id_user) REFERENCES Shop_User(id_user) @@ -22,7 +22,7 @@ CREATE TABLE Shop_Address ( city VARCHAR(50) NOT NULL, county VARCHAR(100) NOT NULL, active BIT NOT NULL DEFAULT 1, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Address_id_change_set diff --git a/static/MySQL/1321_tbl_Shop_User_Basket.sql b/static/MySQL/1321_tbl_Shop_User_Basket.sql index 16e31f63..209e675b 100644 --- a/static/MySQL/1321_tbl_Shop_User_Basket.sql +++ b/static/MySQL/1321_tbl_Shop_User_Basket.sql @@ -7,7 +7,7 @@ SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning CREATE TABLE IF NOT EXISTS Shop_User_Basket ( id_item INT NOT NULL AUTO_INCREMENT PRIMARY KEY, - id_user VARCHAR(200) NOT NULL, + id_user INT NOT NULL, CONSTRAINT FK_Shop_User_Basket_id_user FOREIGN KEY (id_user) REFERENCES Shop_User(id_user) @@ -24,7 +24,7 @@ CREATE TABLE IF NOT EXISTS Shop_User_Basket ( ON UPDATE RESTRICT, quantity INT NOT NULL, active BIT NOT NULL DEFAULT 1, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set_user INT, CONSTRAINT FK_Shop_User_Basket_id_change_set_user diff --git a/static/MySQL/1397_tbl_Shop_Order_Status.sql b/static/MySQL/1397_tbl_Shop_Order_Status.sql index 2a72d447..ef00eb83 100644 --- a/static/MySQL/1397_tbl_Shop_Order_Status.sql +++ b/static/MySQL/1397_tbl_Shop_Order_Status.sql @@ -12,7 +12,7 @@ CREATE TABLE IF NOT EXISTS Shop_User_Order_Status ( name_plural VARCHAR(256), active BIT NOT NULL DEFAULT 1, display_order INT NOT NULL, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_User_Order_Status_id_change_set diff --git a/static/MySQL/1400_tbl_Shop_Supplier.sql b/static/MySQL/1400_tbl_Shop_Supplier.sql index c43753b7..db045ffd 100644 --- a/static/MySQL/1400_tbl_Shop_Supplier.sql +++ b/static/MySQL/1400_tbl_Shop_Supplier.sql @@ -23,7 +23,7 @@ CREATE TABLE IF NOT EXISTS Shop_Supplier ( FOREIGN KEY (id_currency) REFERENCES Shop_Currency(id_currency), active BIT NOT NULL DEFAULT 1, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Supplier_id_change_set diff --git a/static/MySQL/1409_tbl_Shop_Supplier_Purchase_Order.sql b/static/MySQL/1409_tbl_Shop_Supplier_Purchase_Order.sql index dabd6e38..c33e23c1 100644 --- a/static/MySQL/1409_tbl_Shop_Supplier_Purchase_Order.sql +++ b/static/MySQL/1409_tbl_Shop_Supplier_Purchase_Order.sql @@ -30,9 +30,9 @@ CREATE TABLE IF NOT EXISTS Shop_Supplier_Purchase_Order ( display_order INT NOT NULL, */ active BIT NOT NULL DEFAULT 1, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), - updated_last_on DATETIME NULL, + updated_last_on TIMESTAMP NULL, created_last_by VARCHAR(100) NULL, id_change_set INT NULL, CONSTRAINT FK_Shop_Supplier_Purchase_Order_id_change_set diff --git a/static/MySQL/1412_tbl_Shop_Supplier_Purchase_Order_Product_Link.sql b/static/MySQL/1412_tbl_Shop_Supplier_Purchase_Order_Product_Link.sql index 569724ec..9db6ef0c 100644 --- a/static/MySQL/1412_tbl_Shop_Supplier_Purchase_Order_Product_Link.sql +++ b/static/MySQL/1412_tbl_Shop_Supplier_Purchase_Order_Product_Link.sql @@ -26,9 +26,9 @@ CREATE TABLE IF NOT EXISTS Shop_Supplier_Purchase_Order_Product_Link ( latency_delivery_days INT NOT NULL, display_order INT NOT NULL, active BIT NOT NULL, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), - updated_last_on DATETIME NULL, + updated_last_on TIMESTAMP NULL, created_last_by VARCHAR(100) NULL, id_change_set INT NULL, CONSTRAINT FK_Shop_Supplier_Purchase_Order_Product_Link_id_change_set diff --git a/static/MySQL/1414_tbl_Shop_Supplier_Purchase_Order_Product_Link_Temp.sql b/static/MySQL/1414_tbl_Shop_Supplier_Purchase_Order_Product_Link_Temp.sql index 6a0a2cd1..40e5321f 100644 --- a/static/MySQL/1414_tbl_Shop_Supplier_Purchase_Order_Product_Link_Temp.sql +++ b/static/MySQL/1414_tbl_Shop_Supplier_Purchase_Order_Product_Link_Temp.sql @@ -9,7 +9,7 @@ SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning CREATE TABLE IF NOT EXISTS Shop_Supplier_Purchase_Order_Product_Link_Temp ( id_link INT NOT NULL PRIMARY KEY, - GUID VARCHAR(36) NOT NULL, + GUID BINARY(36) NOT NULL, id_order INT NOT NULL, /* CONSTRAINT FK_Supplier_Purchase_Order_Product_Link_Temp_id_order diff --git a/static/MySQL/1415_tbl_Shop_Manufacturing_Purchase_Order.sql b/static/MySQL/1415_tbl_Shop_Manufacturing_Purchase_Order.sql index 917ab435..97edcdcf 100644 --- a/static/MySQL/1415_tbl_Shop_Manufacturing_Purchase_Order.sql +++ b/static/MySQL/1415_tbl_Shop_Manufacturing_Purchase_Order.sql @@ -22,9 +22,9 @@ CREATE TABLE IF NOT EXISTS Shop_Manufacturing_Purchase_Order ( display_order INT NOT NULL, */ active BIT NOT NULL DEFAULT 1, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), - updated_last_on DATETIME NULL, + updated_last_on TIMESTAMP NULL, created_last_by VARCHAR(100) NULL, id_change_set INT NULL, CONSTRAINT FK_Shop_Manufacturing_Purchase_Order_id_change_set diff --git a/static/MySQL/1418_tbl_Shop_Manufacturing_Purchase_Order_Product_Link.sql b/static/MySQL/1418_tbl_Shop_Manufacturing_Purchase_Order_Product_Link.sql index cccacefd..81914291 100644 --- a/static/MySQL/1418_tbl_Shop_Manufacturing_Purchase_Order_Product_Link.sql +++ b/static/MySQL/1418_tbl_Shop_Manufacturing_Purchase_Order_Product_Link.sql @@ -27,9 +27,9 @@ CREATE TABLE IF NOT EXISTS Shop_Manufacturing_Purchase_Order_Product_Link ( quantity_produced FLOAT NOT NULL, display_order INT NOT NULL, active BIT NOT NULL, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), - updated_last_on DATETIME NULL, + updated_last_on TIMESTAMP NULL, created_last_by VARCHAR(100) NULL, id_change_set INT NULL, CONSTRAINT FK_Manufacturing_Purchase_Order_id_change_set diff --git a/static/MySQL/1420_tbl_Shop_Manufacturing_Purchase_Order_Product_Link_Temp.sql b/static/MySQL/1420_tbl_Shop_Manufacturing_Purchase_Order_Product_Link_Temp.sql index b3a1caf3..59a60438 100644 --- a/static/MySQL/1420_tbl_Shop_Manufacturing_Purchase_Order_Product_Link_Temp.sql +++ b/static/MySQL/1420_tbl_Shop_Manufacturing_Purchase_Order_Product_Link_Temp.sql @@ -10,7 +10,7 @@ SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning CREATE TABLE IF NOT EXISTS Shop_Manufacturing_Purchase_Order_Product_Link_Temp ( id_link INT NOT NULL PRIMARY KEY, - GUID VARCHAR(36) NOT NULL, + GUID BINARY(36) NOT NULL, id_order INT NOT NULL, /* CONSTRAINT FK_Manuf_Purch_Order_Product_Link_Temp_id_order diff --git a/static/MySQL/1421_tbl_Shop_Customer.sql b/static/MySQL/1421_tbl_Shop_Customer.sql index 0ffdd449..b15f5952 100644 --- a/static/MySQL/1421_tbl_Shop_Customer.sql +++ b/static/MySQL/1421_tbl_Shop_Customer.sql @@ -20,7 +20,7 @@ CREATE TABLE IF NOT EXISTS Shop_Customer ( FOREIGN KEY (id_currency) REFERENCES Shop_Currency(id_currency), active BIT NOT NULL DEFAULT 1, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Customer_id_change_set diff --git a/static/MySQL/1424_tbl_Shop_Customer_Sales_Order.sql b/static/MySQL/1424_tbl_Shop_Customer_Sales_Order.sql index 8c6cfae3..52bd78dd 100644 --- a/static/MySQL/1424_tbl_Shop_Customer_Sales_Order.sql +++ b/static/MySQL/1424_tbl_Shop_Customer_Sales_Order.sql @@ -24,9 +24,9 @@ CREATE TABLE IF NOT EXISTS Shop_Customer_Sales_Order ( display_order INT NOT NULL, */ active BIT NOT NULL DEFAULT 1, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), - updated_last_on DATETIME NULL, + updated_last_on TIMESTAMP NULL, created_last_by VARCHAR(100) NULL, id_change_set INT NULL, CONSTRAINT FK_Shop_Customer_Sales_Order_id_change_set diff --git a/static/MySQL/1427_tbl_Shop_Customer_Sales_Order_Product_Link.sql b/static/MySQL/1427_tbl_Shop_Customer_Sales_Order_Product_Link.sql index ba8e6779..1bb654c4 100644 --- a/static/MySQL/1427_tbl_Shop_Customer_Sales_Order_Product_Link.sql +++ b/static/MySQL/1427_tbl_Shop_Customer_Sales_Order_Product_Link.sql @@ -27,9 +27,9 @@ CREATE TABLE IF NOT EXISTS Shop_Customer_Sales_Order_Product_Link ( display_order INT NOT NULL, active BIT NOT NULL, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), - updated_last_on DATETIME NULL, + updated_last_on TIMESTAMP NULL, created_last_by VARCHAR(100) NULL, id_change_set INT NULL, CONSTRAINT FK_Shop_Customer_Sales_Order_Product_Link_id_change_set diff --git a/static/MySQL/1429_tbl_Shop_Customer_Sales_Order_Product_Link_Temp.sql b/static/MySQL/1429_tbl_Shop_Customer_Sales_Order_Product_Link_Temp.sql index 3435aa21..a5e5d5f2 100644 --- a/static/MySQL/1429_tbl_Shop_Customer_Sales_Order_Product_Link_Temp.sql +++ b/static/MySQL/1429_tbl_Shop_Customer_Sales_Order_Product_Link_Temp.sql @@ -9,7 +9,7 @@ SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning CREATE TABLE IF NOT EXISTS Shop_Customer_Sales_Order_Product_Link_Temp ( id_link INT NOT NULL PRIMARY KEY, - GUID VARCHAR(36) NOT NULL, + GUID BINARY(36) NOT NULL, id_order INT NOT NULL, /* CONSTRAINT FK_Customer_Sales_Order_Product_Link_Temp_id_order diff --git a/static/MySQL/3312_tri_Shop_User.sql b/static/MySQL/3312_tri_Shop_User.sql index 5bbe92a2..cfe8173a 100644 --- a/static/MySQL/3312_tri_Shop_User.sql +++ b/static/MySQL/3312_tri_Shop_User.sql @@ -39,9 +39,25 @@ BEGIN value_new, id_change_set ) - # Changed name - SELECT NEW.id_user, 'name', OLD.name, NEW.name, NEW.id_change_set - WHERE NOT (OLD.name <=> NEW.name) + # Changed id_user_auth0 + SELECT NEW.id_user, 'id_user_auth0', OLD.id_user_auth0, NEW.id_user_auth0, NEW.id_change_set + WHERE NOT (OLD.id_user_auth0 <=> NEW.id_user_auth0) + UNION + # Changed firstname + SELECT NEW.id_user, 'firstname', OLD.firstname, NEW.firstname, NEW.id_change_set + WHERE NOT (OLD.firstname <=> NEW.firstname) + UNION + # Changed surname + SELECT NEW.id_user, 'surname', OLD.surname, NEW.surname, NEW.id_change_set + WHERE NOT (OLD.surname <=> NEW.surname) + UNION + # Changed email + SELECT NEW.id_user, 'email', OLD.email, NEW.email, NEW.id_change_set + WHERE NOT (OLD.email <=> NEW.email) + UNION + # Changed is_email_verified + SELECT NEW.id_user, 'is_email_verified', CONVERT(CONVERT(OLD.is_email_verified, SIGNED), CHAR), CONVERT(CONVERT(NEW.is_email_verified, SIGNED), CHAR), NEW.id_change_set + WHERE NOT (OLD.is_email_verified <=> NEW.is_email_verified) UNION # Changed is_super_user SELECT NEW.id_user, 'is_super_user', CONVERT(CONVERT(OLD.is_super_user, SIGNED), CHAR), CONVERT(CONVERT(NEW.is_super_user, SIGNED), CHAR), NEW.id_change_set @@ -50,6 +66,18 @@ BEGIN # Changed active SELECT NEW.id_user, 'active', CONVERT(CONVERT(OLD.active, SIGNED), CHAR), CONVERT(CONVERT(NEW.active, SIGNED), CHAR), NEW.id_change_set WHERE NOT (OLD.active <=> NEW.active) + UNION + # Changed id_currency_default + SELECT NEW.id_user, 'id_currency_default', CONVERT(OLD.id_currency_default, CHAR), CONVERT(NEW.id_currency_default, CHAR), NEW.id_change_set + WHERE NOT (OLD.id_currency_default <=> NEW.id_currency_default) + UNION + # Changed id_region_default + SELECT NEW.id_user, 'id_region_default', CONVERT(OLD.id_region_default, CHAR), CONVERT(NEW.id_region_default, CHAR), NEW.id_change_set + WHERE NOT (OLD.id_region_default <=> NEW.id_region_default) + UNION + # Changed is_included_VAT_default + SELECT NEW.id_user, 'is_included_VAT_default', CONVERT(CONVERT(OLD.is_included_VAT_default, SIGNED), CHAR), CONVERT(CONVERT(NEW.is_included_VAT_default, SIGNED), CHAR), NEW.id_change_set + WHERE NOT (OLD.is_included_VAT_default <=> NEW.is_included_VAT_default) ; END // DELIMITER ; \ No newline at end of file diff --git a/static/MySQL/6000_p_split.sql b/static/MySQL/6000_p_split.sql index 883f2912..6bff6fba 100644 --- a/static/MySQL/6000_p_split.sql +++ b/static/MySQL/6000_p_split.sql @@ -31,22 +31,11 @@ BEGIN DECLARE v_i_end INT; DECLARE v_current_item VARCHAR(4000); + -- Argument validation + default values - IF a_string IS NULL THEN - SET a_string = ''; - ELSE - SET a_string = TRIM(a_string); - END IF; - IF a_separator IS NULL THEN - SET a_separator = ''; - ELSE - SET a_separator = TRIM(a_separator); - END IF; - /* - IF a_allow_empty IS NULL THEN - SET a_allow_empty = 0; - END IF; - */ + SET a_string := IFNULL(a_string, ''); + SET a_separator := IFNULL(a_separator, ''); + -- Temporary tables DROP TABLE IF EXISTS Split_Temp; @@ -61,7 +50,7 @@ BEGIN SET v_has_string = CASE WHEN a_string = '' THEN 0 ELSE 1 END; SET v_has_separator = CASE WHEN a_separator = '' THEN 0 ELSE 1 END; - IF (v_has_string AND v_has_separator) THEN + IF v_has_string THEN SET v_i_start = 1; SET v_i_end = LOCATE(',', a_string); diff --git a/static/MySQL/6500_p_shop_user_eval.sql b/static/MySQL/6500_p_shop_user_eval.sql index 5216f5f6..bf7bd77c 100644 --- a/static/MySQL/6500_p_shop_user_eval.sql +++ b/static/MySQL/6500_p_shop_user_eval.sql @@ -6,7 +6,7 @@ USE PARTSLTD_PROD; CALL p_shop_user_eval ( UUID(), # a_guid - '', # a_id_user + '', # a_ids_user 0, # a_get_inactive_users '1', # a_ids_permission '', # a_ids_access_level @@ -21,8 +21,8 @@ DROP PROCEDURE IF EXISTS p_shop_user_eval; DELIMITER // CREATE PROCEDURE p_shop_user_eval ( - IN a_guid VARCHAR(36), - IN a_id_user VARCHAR(200), + IN a_guid BINARY(36), + IN a_ids_user LONGTEXT, IN a_get_inactive_users BIT, IN a_ids_permission VARCHAR(500), IN a_ids_access_level VARCHAR(100), @@ -45,7 +45,7 @@ BEGIN DECLARE v_priority_access_level_admin INT; DECLARE v_id_access_level INT; DECLARE v_priority_access_level INT; - DECLARE v_now DATETIME; + DECLARE v_now TIMESTAMP; DECLARE v_ids_row_delete VARCHAR(500); DECLARE v_code_error_data VARCHAR(200); DECLARE v_id_error_data INT; @@ -64,52 +64,18 @@ BEGIN -- Parse arguments + get default values - /* - IF a_guid IS NULL THEN - SET a_guid = UUID(); - END IF; - */ - IF a_id_user IS NULL THEN - SET a_id_user = ''; - ELSE - SET a_id_user = TRIM(a_id_user); - END IF; - IF a_get_inactive_users IS NULL THEN - SET a_get_inactive_users = 0; - END IF; - /* - IF a_get_user_permissions IS NULL THEN - SET a_get_user_permissions = 0; - END IF; - */ - IF a_ids_permission IS NULL THEN - SET a_ids_permission = ''; - ELSE - SET a_ids_permission = TRIM(a_ids_permission); - END IF; - IF a_ids_access_level IS NULL THEN - SET a_ids_access_level = ''; - ELSE - SET a_ids_access_level = TRIM(a_ids_access_level); - END IF; - /* - IF a_ids_permutation IS NULL THEN - SET a_ids_permutation = ''; - ELSE - SET a_ids_permutation = TRIM(a_ids_permutation); - END IF; - */ - IF a_ids_product IS NULL THEN - SET a_ids_product = ''; - ELSE - SET a_ids_product = TRIM(a_ids_product); - END IF; + SET a_guid := IFNULL(a_guid, UUID()); + SET a_ids_user := TRIM(IFNULL(a_ids_user, '')); + SET a_get_inactive_users := IFNULL(a_get_inactive_users, 0); + SET a_ids_permission := TRIM(IFNULL(a_ids_permission, '')); + SET a_ids_access_level := TRIM(IFNULL(a_ids_access_level, '')); + SET a_ids_product := TRIM(IFNULL(a_ids_product, '')); -- Permanent Table CREATE TABLE IF NOT EXISTS Shop_User_Eval_Temp ( id_row INT PRIMARY KEY AUTO_INCREMENT NOT NULL, - guid VARCHAR(36) NOT NULL, - id_user VARCHAR(200), + guid BINARY(36) NOT NULL, + id_user INT NULL, id_permission_required INT NOT NULL, CONSTRAINT FK_Shop_User_Eval_Temp_id_permission_required FOREIGN KEY (id_permission_required) @@ -148,30 +114,18 @@ BEGIN can_admin BIT -- DEFAULT 0 ); - CREATE TABLE IF NOT EXISTS tmp_Shop_Product_p_Shop_User_Eval ( + CREATE TEMPORARY TABLE IF NOT EXISTS tmp_Shop_Product_p_Shop_User_Eval ( id_row INT PRIMARY KEY AUTO_INCREMENT NOT NULL, id_product INT NOT NULL, - CONSTRAINT FK_tmp_Shop_Product_p_Shop_User_Eval_id_product FOREIGN KEY (id_product) - REFERENCES Shop_Product (id_product), - /* - id_permutation INT NOT NULL, - CONSTRAINT FK_tmp_Shop_Product_p_Shop_User_Eval_id_permutation FOREIGN KEY (id_permutation) - REFERENCES Shop_Product_Permutation (id_permutation), - */ id_access_level_required INT NOT NULL, - CONSTRAINT FK_tmp_Shop_Product_p_Shop_User_Eval_id_access_level_required FOREIGN KEY (id_access_level_required) - REFERENCES Shop_Access_Level (id_access_level), - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, rank_product INT NOT NULL ); - CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( + CREATE TEMPORARY TABLE IF NOT EXISTS tmp_Msg_Error ( display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + 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 ); @@ -194,7 +148,7 @@ BEGIN ) ; END IF; - SET v_has_filter_user = CASE WHEN a_id_user = '' THEN 0 ELSE 1 END; + SET v_has_filter_user = CASE WHEN a_ids_user = '' THEN 0 ELSE 1 END; SET a_ids_permission = REPLACE(a_ids_permission, '|', ','); SET v_has_filter_permission = CASE WHEN a_ids_permission = '' THEN 0 ELSE 1 END; SET a_ids_access_level = REPLACE(a_ids_access_level, '|', ','); @@ -441,10 +395,10 @@ BEGIN IF NOT EXISTS (SELECT * FROM tmp_Msg_Error WHERE GUID = a_guid) THEN IF v_has_filter_user = 1 THEN /* - SET a_id_user := (SELECT id_user FROM Shop_User WHERE id_user LIKE a_id_user AND active); - SET v_has_filter_user = NOT (a_id_user <=> NULL); + SET a_ids_user := (SELECT id_user FROM Shop_User WHERE id_user LIKE a_ids_user AND active); + SET v_has_filter_user = NOT (a_ids_user <=> NULL); */ - IF ISNULL((SELECT id_user FROM Shop_User WHERE id_user LIKE a_id_user AND active)) THEN -- NOT v_has_filter_user THEN + IF ISNULL((SELECT id_user FROM Shop_User WHERE id_user LIKE a_ids_user AND active)) THEN -- NOT v_has_filter_user THEN INSERT INTO tmp_Msg_Error ( guid, id_type, @@ -455,10 +409,10 @@ BEGIN a_guid, (SELECT id_type FROM Shop_Msg_Error_Type WHERE code = v_code_error_data LIMIT 1), v_code_error_data, - CONCAT('Invalid user ID: ', IFNULL(a_id_user, 'NULL')) + CONCAT('Invalid user ID: ', IFNULL(a_ids_user, 'NULL')) ) ; - SET a_id_user = NULL; + SET a_ids_user = NULL; SET v_has_filter_user = 0; ELSE SET v_has_filter_user = 1; @@ -482,13 +436,20 @@ BEGIN */ ) SELECT a_guid, - a_id_user, + U.id_user, P.id_permission, AL.priority FROM Shop_Permission P INNER JOIN Shop_Access_Level AL ON P.id_access_level_required = AL.id_access_level - AND AL.active + AND AL.active + CROSS JOIN ( + SELECT id_user + FROM Shop_User U + WHERE 1=1 + AND FIND_IN_SET(U.id_user, a_ids_user) > 0 + AND U.active + ) U WHERE FIND_IN_SET(P.id_permission, a_ids_permission) > 0 ; @@ -515,7 +476,7 @@ BEGIN ON t_P.id_access_leveL_required = AL.id_access_level AND AL.active CROSS JOIN Shop_User_Eval_Temp UE_T - ON a_id_user = UE_T.id_user + ON a_ids_user = UE_T.id_user WHERE a_guid = t_P.guid ; @@ -546,7 +507,7 @@ BEGIN ON t_P.id_access_leveL_required = AL.id_access_level AND AL.active CROSS JOIN Shop_User_Eval_Temp UE_T - ON a_id_user = UE_T.id_user + ON a_ids_user = UE_T.id_user WHERE a_guid = t_P.guid ; @@ -598,7 +559,7 @@ BEGIN INNER JOIN Shop_Access_Level AL ON RPL.id_access_level = AL.id_access_level AND AL.active - WHERE U.id_user = a_id_user + WHERE U.id_user = a_ids_user AND (a_get_inactive_users OR U.active) AND FIND_IN_SET(P.id_permission, a_ids_permission) > 0 # AND v_id_permission = P.id_permission @@ -627,7 +588,7 @@ BEGIN UE_T.can_edit = CASE WHEN U.is_super_user THEN 1 ELSE CASE WHEN NOT ISNULL(AL.priority) AND AL.priority <= v_priority_access_level_edit AND AL.priority <= UE_T.priority_access_level_required THEN 1 ELSE 0 END END, UE_T.can_admin = CASE WHEN U.is_super_user THEN 1 ELSE CASE WHEN NOT ISNULL(AL.priority) AND AL.priority <= v_priority_access_level_admin AND AL.priority <= UE_T.priority_access_level_required THEN 1 ELSE 0 END END WHERE UE_T.guid = a_guid - AND UE_T.id_user = a_id_user + AND UE_T.id_user = a_ids_user AND RPL.id_permission = UE_T.id_permission_required # GROUP BY UE_T.id_user ; @@ -639,7 +600,7 @@ BEGIN UE_T.can_edit = 0, UE_T.can_admin = 0 WHERE UE_T.guid = a_guid - AND UE_T.id_user = a_id_user + AND UE_T.id_user = a_ids_user # GROUP BY UE_T.id_user ; END IF; @@ -680,7 +641,7 @@ select * from shop_product; CALL p_shop_user_eval ( -- '00550ef3-2bfa-11ef-b83e-b42e9986184a', NULL, 0, '2', '1', '1,2,3,4,5,6'); '56c9dfc1-e22f-11ee-aab4-b42e9986184a', # a_guid - '', # a_id_user # 'auth0|6582b95c895d09a70ba10fef', + '', # a_ids_user # 'auth0|6582b95c895d09a70ba10fef', false, # a_get_inactive_users '4,5', # a_ids_permission '1', # a_ids_access_level diff --git a/static/MySQL/7203_p_shop_save_product.sql b/static/MySQL/7203_p_shop_save_product.sql index 5fcbc2ec..78234442 100644 --- a/static/MySQL/7203_p_shop_save_product.sql +++ b/static/MySQL/7203_p_shop_save_product.sql @@ -4,15 +4,22 @@ USE PARTSLTD_PROD; -- Clear previous proc DROP PROCEDURE IF EXISTS p_save_product; +DROP PROCEDURE IF EXISTS p_shop_save_product; DELIMITER // -CREATE PROCEDURE p_save_product ( +CREATE PROCEDURE p_shop_save_product ( IN a_guid BINARY(36), - IN a_id_user VARCHAR(200), + IN a_id_user INT, IN a_comment VARCHAR(500) ) 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 exit handler for SQLEXCEPTION BEGIN -- Get diagnostic information @@ -40,13 +47,9 @@ BEGIN , @text ; END; - DECLARE v_code_type_error_bad_data VARCHAR(100); - DECLARE v_id_type_error_bad_data INT; - DECLARE v_ids_product_permission LONGTEXT; 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_now := NOW(); SET a_guid := IFNULL(a_guid, UUID()); @@ -165,23 +168,21 @@ BEGIN 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(item SEPARATOR ',') FROM tmp_Shop_Product WHERE is_new = 0); IF NOT ISNULL(v_ids_product_permission) THEN - SET v_guid_permission = UUID(); - SET v_id_user = CURRENT_USER(); SET v_id_permission_product = (SELECT id_permission FROM Shop_Permission WHERE code = 'STORE_PRODUCT' LIMIT 1); - CALL p_shop_user_eval(v_guid_permission, v_id_user, v_id_permission_product, v_ids_product_permission); + CALL p_shop_user_eval(a_guid, a_id_user, v_id_permission_product, v_ids_product_permission); UPDATE tmp_Product t_P INNER JOIN Shop_User_Eval_Temp UE_T ON t_P.id_product = UE_T.id_product - AND UE_T.GUID = v_guid_permission + 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_shop_user_eval_clear_temp(v_guid_permission); + CALL p_shop_user_eval_clear_temp(a_guid); END IF; END IF; diff --git a/static/MySQL/7204_p_shop_get_many_product.sql b/static/MySQL/7204_p_shop_get_many_product.sql index 9ee2547c..470c181b 100644 --- a/static/MySQL/7204_p_shop_get_many_product.sql +++ b/static/MySQL/7204_p_shop_get_many_product.sql @@ -7,7 +7,7 @@ DROP PROCEDURE IF EXISTS p_shop_get_many_product; DELIMITER // CREATE PROCEDURE p_shop_get_many_product ( - IN a_id_user VARCHAR(200), + IN a_id_user INT, IN a_get_all_category BIT, IN a_get_inactive_category BIT, IN a_get_first_category_only BIT, @@ -51,14 +51,14 @@ BEGIN DECLARE v_has_filter_delivery_region BIT; DECLARE v_has_filter_currency BIT; DECLARE v_has_filter_discount BIT; - DECLARE v_guid VARCHAR(36); + DECLARE v_guid BINARY(36); # DECLARE v_id_user VARCHAR(100); DECLARE v_ids_permutation_unavailable VARCHAR(4000); DECLARE v_id_permission_product INT; DECLARE v_ids_product_permission VARCHAR(4000); -- DECLARE v_ids_permutation_permission VARCHAR(4000); DECLARE v_id_access_level_view INT; - -- DECLARE v_now DATETIME; + -- DECLARE v_now TIMESTAMP; DECLARE v_id_minimum INT; SET v_guid := UUID(); @@ -289,7 +289,7 @@ BEGIN CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, id_type INT NOT NULL, CONSTRAINT FK_tmp_Msg_Error_id_type FOREIGN KEY (id_type) diff --git a/static/MySQL/7205_p_shop_get_many_stripe_product_new.sql b/static/MySQL/7205_p_shop_get_many_stripe_product_new.sql index bcf91c23..7c55f5d7 100644 --- a/static/MySQL/7205_p_shop_get_many_stripe_product_new.sql +++ b/static/MySQL/7205_p_shop_get_many_stripe_product_new.sql @@ -16,13 +16,13 @@ DROP PROCEDURE IF EXISTS p_shop_get_many_stripe_product_new; DELIMITER // CREATE PROCEDURE p_shop_get_many_stripe_product_new ( - IN a_id_user VARCHAR(200) + IN a_id_user INT ) BEGIN DECLARE v_has_filter_user BIT; DECLARE v_code_error_data VARCHAR(200); DECLARE v_code_error_permission VARCHAR(200); - DECLARE v_guid VARCHAR(36); + DECLARE v_guid BINARY(36); SET v_code_error_data := (SELECT code FROM Shop_Msg_Error_Type WHERE id_type = 1); SET v_code_error_permission := (SELECT code FROM Shop_Msg_Error_Type WHERE id_type = 2); @@ -42,7 +42,7 @@ BEGIN DROP TABLE IF EXISTS tmp_Shop_User; CREATE TABLE tmp_Shop_User( - id_user VARCHAR(200) NOT NULL PRIMARY KEY, + id_user INT NOT NULL PRIMARY KEY, CONSTRAINT FK_tmp_Shop_User_id_user FOREIGN KEY (id_user) REFERENCES Shop_User(id_user), @@ -67,7 +67,7 @@ BEGIN CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( # IF NOT EXISTS display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, code VARCHAR(50) NOT NULL, # CONSTRAINT chk_tmp_Msg_Error_code CHECK (code IN (SELECT code FROM Shop_Msg_Error_Type)), /* diff --git a/static/MySQL/7206_p_shop_save_permutation.sql b/static/MySQL/7206_p_shop_save_permutation.sql index edc2be98..94728b46 100644 --- a/static/MySQL/7206_p_shop_save_permutation.sql +++ b/static/MySQL/7206_p_shop_save_permutation.sql @@ -11,7 +11,7 @@ DROP TABLE IF EXISTS tmp_Msg_Error; DELIMITER // CREATE PROCEDURE p_shop_save_permutation ( IN a_guid VARCHAR(500), - IN a_id_user VARCHAR(200), + IN a_id_user INT, IN a_id_order INT, -- IN a_id_supplier_ordered INT, IN a_id_currency_cost INT, @@ -23,7 +23,7 @@ BEGIN 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 VARCHAR(36); + 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; @@ -94,7 +94,7 @@ BEGIN CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, id_type INT NOT NULL, CONSTRAINT FK_tmp_Msg_Error_id_type FOREIGN KEY (id_type) diff --git a/static/MySQL/7219_p_shop_get_many_stock_item.sql b/static/MySQL/7219_p_shop_get_many_stock_item.sql index 3377eb6c..7575b59e 100644 --- a/static/MySQL/7219_p_shop_get_many_stock_item.sql +++ b/static/MySQL/7219_p_shop_get_many_stock_item.sql @@ -8,7 +8,7 @@ DROP PROCEDURE IF EXISTS p_shop_get_many_stock_item; DELIMITER // CREATE PROCEDURE p_shop_get_many_stock_item ( - IN a_id_user VARCHAR(200), + IN a_id_user INT, IN a_get_all_category BIT, IN a_get_inactive_category BIT, IN a_get_first_category_only BIT, @@ -37,7 +37,7 @@ CREATE PROCEDURE p_shop_get_many_stock_item ( IN a_get_inactive_location_storage BIT, IN a_get_first_location_storage_only BIT, IN a_ids_location_storage TEXT, - IN a_date_received_to DATETIME, + IN a_date_received_to TIMESTAMP, IN a_get_sealed_stock_item_only BIT, IN a_get_unsealed_stock_item_only BIT, IN a_get_expired_stock_item_only BIT, @@ -55,15 +55,15 @@ BEGIN DECLARE v_has_filter_region_storage BIT; DECLARE v_has_filter_plant_storage BIT; DECLARE v_has_filter_location_storage BIT; - DECLARE v_guid VARCHAR(36); + DECLARE v_guid BINARY(36); -- DECLARE v_ids_permutation_unavailable LONGTEXT; DECLARE v_id_permission_product INT; DECLARE v_ids_product_permission LONGTEXT; -- DECLARE v_ids_permutation_permission VARCHAR(4000); DECLARE v_id_access_level_view INT; - -- DECLARE v_now DATETIME; + -- DECLARE v_now TIMESTAMP; -- DECLARE v_id_minimum INT; - DECLARE v_now DATETIME; + DECLARE v_now TIMESTAMP; SET v_guid := UUID(); SET v_id_access_level_view := (SELECT id_access_level FROM Shop_Access_Level WHERE code = 'VIEW'); @@ -216,8 +216,8 @@ BEGIN FOREIGN KEY (id_category) REFERENCES Shop_Category(id_category), */ - , date_purchased DATETIME NOT NULL - , date_received DATETIME NULL + , date_purchased TIMESTAMP NOT NULL + , date_received TIMESTAMP NULL , id_location_storage INT NOT NULL /* CONSTRAINT FK_tmp_Stock_Item_id_location_storage @@ -233,10 +233,10 @@ BEGIN , cost_local_VAT_incl FLOAT NOT NULL , cost_local_VAT_excl FLOAT NOT NULL , is_sealed BIT NOT NULL DEFAULT 1 - , date_unsealed DATETIME NULL - , date_expiration DATETIME NOT NULL + , date_unsealed TIMESTAMP NULL + , date_expiration TIMESTAMP NOT NULL , is_consumed BIT NOT NULL DEFAULT 0 - , date_consumed DATETIME NULL + , date_consumed TIMESTAMP NULL , active_stock_item BIT NOT NULL DEFAULT 1 , active_permutation BIT NOT NULL , active_product BIT NOT NULL @@ -284,7 +284,7 @@ BEGIN CREATE TEMPORARY TABLE IF NOT EXISTS tmp_Msg_Error ( display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, id_type INT NOT NULL, /* CONSTRAINT FK_tmp_Msg_Error_id_type @@ -798,8 +798,9 @@ BEGIN END // DELIMITER ; +/* CALL p_shop_get_many_stock_item ( - '', # a_id_user + 0, # a_id_user 1, # a_get_all_category 0, # a_get_inactive_category 0, # a_get_first_category_only @@ -837,7 +838,6 @@ CALL p_shop_get_many_stock_item ( 0 # a_get_nonconsumed_stock_item_only ); -/* DROP TABLE IF EXISTS tmp_Msg_Error; diff --git a/static/MySQL/7223_p_shop_get_many_stripe_price_new.sql b/static/MySQL/7223_p_shop_get_many_stripe_price_new.sql index 3cc738e3..7880d8b8 100644 --- a/static/MySQL/7223_p_shop_get_many_stripe_price_new.sql +++ b/static/MySQL/7223_p_shop_get_many_stripe_price_new.sql @@ -16,13 +16,13 @@ DROP PROCEDURE IF EXISTS p_shop_get_many_stripe_price_new; DELIMITER // CREATE PROCEDURE p_shop_get_many_stripe_price_new ( - IN a_id_user VARCHAR(200) + IN a_id_user INT ) BEGIN DECLARE v_has_filter_user BIT; DECLARE v_code_error_data VARCHAR(200); DECLARE v_code_error_permission VARCHAR(200); - DECLARE v_guid VARCHAR(36); + DECLARE v_guid BINARY(36); SET v_code_error_data := (SELECT code FROM Shop_Msg_Error_Type WHERE id_type = 1); SET v_code_error_permission := (SELECT code FROM Shop_Msg_Error_Type WHERE id_type = 2); @@ -43,7 +43,7 @@ BEGIN DROP TABLE IF EXISTS tmp_Shop_User; CREATE TABLE tmp_Shop_User( - id_user VARCHAR(200) NOT NULL PRIMARY KEY, + id_user INT NOT NULL PRIMARY KEY, CONSTRAINT FK_tmp_Shop_User_id_user FOREIGN KEY (id_user) REFERENCES Shop_User(id_user), @@ -72,7 +72,7 @@ BEGIN CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( # IF NOT EXISTS display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, code VARCHAR(50) NOT NULL, # CONSTRAINT chk_tmp_Msg_Error_code CHECK (code IN (SELECT code FROM Shop_Msg_Error_Type)), /* diff --git a/static/MySQL/7312_p_shop_save_user.sql b/static/MySQL/7312_p_shop_save_user.sql index 3b2b3f9c..cd759078 100644 --- a/static/MySQL/7312_p_shop_save_user.sql +++ b/static/MySQL/7312_p_shop_save_user.sql @@ -19,7 +19,7 @@ DROP PROCEDURE IF EXISTS p_shop_edit_user; DELIMITER // CREATE PROCEDURE p_shop_edit_user ( - IN a_id_user VARCHAR(200), + IN a_id_user INT, IN a_name VARCHAR(255), IN a_email VARCHAR(254), IN a_email_verified BIT @@ -28,7 +28,7 @@ BEGIN -- Argument redeclaration -- Variable declaration DECLARE v_has_filter_user BIT; - -- DECLARE v_now DATETIME; + -- DECLARE v_now TIMESTAMP; -- Argument validation + default values @@ -56,7 +56,7 @@ BEGIN DROP TABLE IF EXISTS tmp_Shop_User; CREATE TABLE tmp_Shop_User ( - id_user VARCHAR(200) NOT NULL, + id_user INT NOT NULL, CONSTRAINT FK_tmp_Shop_User_id_user FOREIGN KEY (id_user) REFERENCES Shop_User(id_user), diff --git a/static/MySQL/7313_p_get_many_user.sql b/static/MySQL/7313_p_get_many_user.sql new file mode 100644 index 00000000..c3189fb1 --- /dev/null +++ b/static/MySQL/7313_p_get_many_user.sql @@ -0,0 +1,231 @@ + +USE PARTSLTD_PROD; + + +-- Clear previous proc +DROP PROCEDURE IF EXISTS p_get_many_user; + + +DELIMITER // +CREATE PROCEDURE p_get_many_user ( + IN a_id_user INT + , IN a_get_all_user BIT + , IN a_get_inactive_user BIT + , IN a_get_first_user_only BIT + , IN a_ids_user LONGTEXT + , IN a_ids_user_auth0 LONGTEXT +) +BEGIN + DECLARE v_id_access_level_view INT; + DECLARE v_id_permission_store_admin INT; + DECLARE v_id_permission_user INT; + DECLARE v_id_permission_user_admin INT; + DECLARE v_now TIMESTAMP; + DECLARE v_id_minimum INT; + DECLARE v_code_error_data VARCHAR(50); + DECLARE v_id_type_error_data INT; + DECLARE v_has_filter_user BIT; + DECLARE v_guid BINARY(36); + + SET v_guid := UUID(); + SET v_id_access_level_view := (SELECT id_access_level FROM Shop_Access_Level WHERE code = 'VIEW' LIMIT 1); + SET v_id_permission_store_admin := (SELECT id_permission FROM Shop_Permission WHERE code = 'STORE_ADMIN' LIMIT 1); + SET v_id_permission_user := (SELECT id_permission FROM Shop_Permission WHERE code = 'STORE_USER' LIMIT 1); + SET v_id_permission_user_admin := (SELECT id_permission FROM Shop_Permission WHERE code = 'STORE_USER_ADMIN' LIMIT 1); + SET v_code_error_data := (SELECT code FROM Shop_Msg_Error_Type WHERE code = 'BAD_DATA' LIMIT 1); + SET v_id_type_error_data := (SELECT id_type FROM Shop_Msg_Error_Type WHERE code = v_code_error_data LIMIT 1); + + SET a_ids_user := TRIM(IFNULL(a_ids_user, '')); + SET a_ids_user_auth0 := TRIM(IFNULL(a_ids_user_auth0, '')); + + DROP TEMPORARY TABLE IF EXISTS tmp_User; + DROP TEMPORARY TABLE IF EXISTS tmp_Msg_Error; + + CREATE TEMPORARY TABLE tmp_User ( + id_user INT NOT NULL, + rank_user INT NULL + ); + + CREATE TEMPORARY TABLE tmp_Msg_Error ( + display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, + guid BINARY(36) NOT NULL, + id_type INT NOT NULL, + code VARCHAR(50) NOT NULL, + msg VARCHAR(4000) NOT NULL + ); + + + SET v_has_filter_user := CASE WHEN a_ids_user = '' AND a_ids_user_auth0= '' THEN 0 ELSE 1 END; + + IF v_has_filter_user THEN + INSERT INTO tmp_User ( + id_user + -- , active + , rank_user + ) + SELECT + DISTINCT U.id_user + -- S.active + , RANK() OVER (ORDER BY id_user ASC) AS rank_user + FROM Shop_User U + WHERE 1=1 + AND ( + FIND_IN_SET(U.id_user, a_ids_user) > 0 + OR FIND_IN_SET(U.id_user_auth0, a_ids_user_auth0) > 0 + ) + AND ( + a_get_inactive_user + OR U.active + ) + /*Shop_User_Eval_Temp UE_T + WHERE 1=1 + AND UE_T.guid = v_guid + AND UE_T.active = 1 + */ + ; + + IF a_get_first_user_only THEN + DELETE FROM tmp_User t_U + WHERE t_U.rank_user > 1 + ; + END IF; + END IF; + + -- Permissions + IF NOT EXISTS (SELECT * FROM tmp_Msg_Error LIMIT 1) THEN + -- SELECT v_guid, a_id_user, false, v_id_permission_product, v_id_access_level_view, v_ids_permutation_permission; + -- select * from Shop_User_Eval_Temp; + + CALL p_shop_user_eval( + v_guid, -- guid + a_id_user, -- ids_user + FALSE, -- get_inactive_user + CONCAT(v_id_permission_user, ',', v_id_permission_user_admin, ',', v_id_permission_store_admin), -- ids_permission + v_id_access_level_view, -- ids_access_level + '' -- ids_product + ); + + -- select * from Shop_User_Eval_Temp; + + IF NOT EXISTS ( + SELECT can_view + FROM Shop_User_Eval_Temp UE_T + WHERE 1=1 + AND UE_T.GUID = v_guid + AND UE_T.id_permission_required = v_id_permission_user + ) THEN + INSERT INTO tmp_Msg_Error ( + guid, + id_type, + code, + msg + ) + VALUES ( + v_guid, + v_id_type_error_data, + v_code_error_data, + CONCAT('You do not have view permissions for ', (SELECT name FROM Shop_Permission WHERE id_permission = v_id_permission_user LIMIT 1)) + ) + ; + END IF; + END IF; + + + -- Returns + /* NULL record required for flask sql_alchemy to detect result set + IF EXISTS (SELECT * FROM tmp_Msg_Error WHERE GUID = v_guid) THEN + DELETE FROM tmp_User; + END IF; + */ + + IF NOT EXISTS (SELECT * FROM tmp_Msg_Error WHERE GUID = v_guid) THEN + SELECT + U.id_user + , U.id_user_auth0 + , U.firstname + , U.surname + , U.email + , U.is_email_verified + , U.id_currency_default + , U.id_region_default + , U.is_included_VAT_default + , U.is_super_user + , UE_T_STORE.can_admin_store AS can_admin_store + , UE_T_USER.can_admin_user AS can_admin_user + FROM tmp_User t_U + INNER JOIN Shop_User U ON t_U.id_user = U.id_user + INNER JOIN ( + SELECT + id_user + , id_permission_required + , can_admin AS can_admin_store + FROM Shop_User_Eval_Temp UE_T_STORE + WHERE 1=1 + AND UE_T_STORE.guid = v_guid + AND UE_T_STORE.id_permission_required = v_id_permission_store_admin + ) UE_T_STORE ON t_U.id_user = UE_T_STORE.id_user + INNER JOIN ( + SELECT + id_user + , id_permission_required + , can_admin AS can_admin_user + FROM Shop_User_Eval_Temp UE_T_USER + WHERE 1=1 + AND UE_T_USER.guid = v_guid + AND UE_T_USER.id_permission_required = v_id_permission_user_admin + ) UE_T_USER ON t_U.id_user = UE_T_USER.id_user + ; + ELSE + SELECT + NULL AS id_user + , NULL AS id_user_auth0 + , NULL AS firstname + , NULL AS surname + , NULL AS email + , NULL AS is_email_verified + , NULL AS id_currency_default + , NULL AS id_region_default + , NULL AS is_included_VAT_default + , NULL AS is_super_user + , NULL AS can_admin_store + , NULL AS can_admin_user + ; + END IF; + + # Errors + SELECT + t_ME.display_order, + MET.code, + t_ME.msg, + MET.name, + MET.description + FROM tmp_Msg_Error t_ME + INNER JOIN Shop_Msg_Error_Type MET + ON t_ME.id_type = MET.id_type + WHERE guid = v_guid + ; + + + -- Clean up + DROP TEMPORARY TABLE IF EXISTS tmp_User; + DROP TEMPORARY TABLE IF EXISTS tmp_Msg_Error; + + DELETE FROM Shop_User_Eval_Temp + WHERE GUID = v_guid + ; +END // +DELIMITER ; + + +/* + +CALL p_get_many_user ( + NULL # a_id_user + , 0 # a_get_all_user + , 0 # a_get_inactive_user + , 0 # a_get_first_user_only + , NULL # a_ids_user + , '' -- auth0|6582b95c895d09a70ba10fef' # a_ids_user_auth0 +); + +*/ diff --git a/static/MySQL/7321_p_shop_save_user_basket.sql b/static/MySQL/7321_p_shop_save_user_basket.sql index 93df5910..8d037cab 100644 --- a/static/MySQL/7321_p_shop_save_user_basket.sql +++ b/static/MySQL/7321_p_shop_save_user_basket.sql @@ -23,7 +23,7 @@ DROP PROCEDURE IF EXISTS p_shop_edit_user_basket; DELIMITER // CREATE PROCEDURE p_shop_edit_user_basket ( - IN a_id_user VARCHAR(200), + IN a_id_user INT, IN a_ids_permutation_basket VARCHAR(4000), IN a_quantities_permutation_basket VARCHAR(4000), IN a_id_permutation_edit INT, @@ -43,11 +43,11 @@ BEGIN DECLARE v_n_id_permutation_basket INT; DECLARE v_n_quantity_permutation_basket INT; DECLARE v_row_number INT; - DECLARE v_guid VARCHAR(36); + DECLARE v_guid BINARY(36); # DECLARE v_id_user VARCHAR(100); DECLARE v_id_permission_product INT; DECLARE v_ids_permutation_permission VARCHAR(4000); - DECLARE v_now DATETIME; + DECLARE v_now TIMESTAMP; # DECLARE v_quantity_new INT; DECLARE v_change_set_used BIT; DECLARE v_id_change_set INT; @@ -82,7 +82,7 @@ BEGIN DROP TABLE IF EXISTS tmp_Shop_User; CREATE TABLE tmp_Shop_User ( - id_user VARCHAR(200) NOT NULL, + id_user INT NOT NULL, CONSTRAINT FK_tmp_Shop_User_id_user FOREIGN KEY (id_user) REFERENCES Shop_User(id_user), @@ -139,7 +139,7 @@ BEGIN CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, id_type INT NOT NULL, # code VARCHAR(50) NOT NULL, # CONSTRAINT chk_tmp_Msg_Error_code CHECK (code IN (SELECT code FROM Shop_Msg_Error_Type)), diff --git a/static/MySQL/7400_p_shop_save_supplier.sql b/static/MySQL/7400_p_shop_save_supplier.sql index 4cfc0c0d..9b670f84 100644 --- a/static/MySQL/7400_p_shop_save_supplier.sql +++ b/static/MySQL/7400_p_shop_save_supplier.sql @@ -9,7 +9,7 @@ DROP PROCEDURE IF EXISTS p_shop_save_supplier; DELIMITER // CREATE PROCEDURE p_shop_save_supplier ( IN a_guid VARCHAR(500), - IN a_id_user VARCHAR(200), + IN a_id_user INT, IN a_comment VARCHAR(500), IN a_id_supplier INT, IN a_name_company VARCHAR(256), @@ -26,7 +26,7 @@ CREATE PROCEDURE p_shop_save_supplier ( BEGIN DECLARE v_id_error_type_bad_data INT; DECLARE v_id_error_type_no_permission INT; - DECLARE v_guid_permission VARCHAR(36); + DECLARE v_guid_permission BINARY(36); DECLARE v_id_user VARCHAR(100); DECLARE v_id_permission_supplier INT; -- DECLARE v_id_access_level_EDIT INT; @@ -74,7 +74,7 @@ BEGIN CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, id_type INT NOT NULL, CONSTRAINT FK_tmp_Msg_Error_id_type FOREIGN KEY (id_type) diff --git a/static/MySQL/7401_p_shop_get_many_supplier.sql b/static/MySQL/7401_p_shop_get_many_supplier.sql index ded4b7ed..8809f9fc 100644 --- a/static/MySQL/7401_p_shop_get_many_supplier.sql +++ b/static/MySQL/7401_p_shop_get_many_supplier.sql @@ -20,7 +20,7 @@ DROP PROCEDURE IF EXISTS p_shop_get_many_supplier; DELIMITER // CREATE PROCEDURE p_shop_get_many_supplier ( - IN a_id_user VARCHAR(200), + IN a_id_user INT, IN a_get_all_supplier BIT, IN a_get_inactive_supplier BIT, IN a_get_first_supplier_only BIT, @@ -30,14 +30,14 @@ BEGIN -- Argument redeclaration -- Variable declaration DECLARE v_has_filter_supplier BIT; - DECLARE v_guid VARCHAR(36); + DECLARE v_guid BINARY(36); # DECLARE v_id_user VARCHAR(100); # DECLARE v_ids_permutation_unavailable VARCHAR(4000); DECLARE v_id_permission_supplier INT; # DECLARE v_ids_product_permission VARCHAR(4000); # DECLARE v_ids_permutation_permission VARCHAR(4000); DECLARE v_id_access_level_view INT; - DECLARE v_now DATETIME; + DECLARE v_now TIMESTAMP; DECLARE v_id_minimum INT; DECLARE v_code_error_data VARCHAR(50); @@ -81,7 +81,7 @@ BEGIN CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, id_type INT NOT NULL, CONSTRAINT FK_tmp_Msg_Error_id_type FOREIGN KEY (id_type) @@ -266,4 +266,4 @@ insert into shop_product_change_set (comment) set is_subscription = 0, id_change_set = (select id_change_set from shop_product_change_set order by id_change_set desc limit 1) where id_product = 1 -*/ +*/ \ No newline at end of file diff --git a/static/MySQL/7403_p_save_supplier_purchase_order.sql b/static/MySQL/7403_p_save_supplier_purchase_order.sql index e5848902..26e6dfd5 100644 --- a/static/MySQL/7403_p_save_supplier_purchase_order.sql +++ b/static/MySQL/7403_p_save_supplier_purchase_order.sql @@ -11,7 +11,7 @@ DROP TABLE IF EXISTS tmp_Msg_Error; DELIMITER // CREATE PROCEDURE p_shop_save_supplier_purchase_order ( IN a_guid VARCHAR(500), - IN a_id_user VARCHAR(200), + IN a_id_user INT, IN a_comment VARCHAR(500), IN a_id_order INT, IN a_id_supplier_ordered INT, @@ -23,7 +23,7 @@ BEGIN 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 VARCHAR(36); + DECLARE v_guid_permission BINARY(36); -- DECLARE v_id_user VARCHAR(100); DECLARE v_id_permission_supplier_purchase_order INT; DECLARE v_id_access_level_EDIT INT; @@ -95,7 +95,7 @@ BEGIN CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, id_type INT NOT NULL, CONSTRAINT FK_tmp_Msg_Error_id_type FOREIGN KEY (id_type) diff --git a/static/MySQL/7404_p_shop_get_many_supplier_purchase_order.sql b/static/MySQL/7404_p_shop_get_many_supplier_purchase_order.sql index d8216eb5..5ce77c29 100644 --- a/static/MySQL/7404_p_shop_get_many_supplier_purchase_order.sql +++ b/static/MySQL/7404_p_shop_get_many_supplier_purchase_order.sql @@ -8,7 +8,7 @@ DROP PROCEDURE IF EXISTS p_shop_get_many_supplier_purchase_order; DELIMITER // CREATE PROCEDURE p_shop_get_many_supplier_purchase_order ( - IN a_id_user VARCHAR(200), + IN a_id_user INT, IN a_get_all_supplier BIT, IN a_get_inactive_supplier BIT, IN a_get_first_supplier_only BIT, @@ -23,8 +23,8 @@ CREATE PROCEDURE p_shop_get_many_supplier_purchase_order ( IN a_ids_product VARCHAR(4000), IN a_get_inactive_permutation BIT, IN a_ids_permutation VARCHAR(4000), - IN a_date_from DATETIME, - IN a_date_to DATETIME + IN a_date_from TIMESTAMP, + IN a_date_to TIMESTAMP ) BEGIN -- Argument redeclaration @@ -36,14 +36,14 @@ BEGIN DECLARE v_has_filter_permutation BIT; DECLARE v_has_filter_date_from BIT; DECLARE v_has_filter_date_to BIT; - DECLARE v_guid VARCHAR(36); + DECLARE v_guid BINARY(36); # DECLARE v_id_user VARCHAR(100); # DECLARE v_ids_permutation_unavailable VARCHAR(4000); DECLARE v_ids_permission_supplier_purchase_order VARCHAR(4000); DECLARE v_ids_product_permission VARCHAR(4000); # DECLARE v_ids_permutation_permission VARCHAR(4000); DECLARE v_id_access_level_view INT; - -- DECLARE v_now DATETIME; + -- DECLARE v_now TIMESTAMP; -- DECLARE v_id_minimum INT; DECLARE v_code_error_data VARCHAR(50); DECLARE v_id_type_error_data INT; @@ -216,7 +216,7 @@ BEGIN CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, id_type INT NOT NULL, CONSTRAINT FK_tmp_Msg_Error_id_type FOREIGN KEY (id_type) diff --git a/static/MySQL/7415_p_shop_save_manufacturing_purchase_order.sql b/static/MySQL/7415_p_shop_save_manufacturing_purchase_order.sql index 3590e1c0..068fa669 100644 --- a/static/MySQL/7415_p_shop_save_manufacturing_purchase_order.sql +++ b/static/MySQL/7415_p_shop_save_manufacturing_purchase_order.sql @@ -11,7 +11,7 @@ DROP TABLE IF EXISTS tmp_Msg_Error; DELIMITER // CREATE PROCEDURE p_shop_save_manufacturing_purchase_order ( IN a_guid VARCHAR(500), - IN a_id_user VARCHAR(200), + IN a_id_user INT, IN a_id_order INT, -- IN a_id_supplier_ordered INT, IN a_id_currency_cost INT, @@ -23,7 +23,7 @@ BEGIN 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 VARCHAR(36); + 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; @@ -94,7 +94,7 @@ BEGIN CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, id_type INT NOT NULL, CONSTRAINT FK_tmp_Msg_Error_id_type FOREIGN KEY (id_type) diff --git a/static/MySQL/7416_p_shop_get_many_manufacturing_purchase_order.sql b/static/MySQL/7416_p_shop_get_many_manufacturing_purchase_order.sql index 9a8d0281..33883603 100644 --- a/static/MySQL/7416_p_shop_get_many_manufacturing_purchase_order.sql +++ b/static/MySQL/7416_p_shop_get_many_manufacturing_purchase_order.sql @@ -8,7 +8,7 @@ DROP PROCEDURE IF EXISTS p_shop_get_many_manufacturing_purchase_order; DELIMITER // CREATE PROCEDURE p_shop_get_many_manufacturing_purchase_order ( - IN a_id_user VARCHAR(200), + IN a_id_user INT, IN a_get_all_order BIT, -- IN a_get_inactive_order BIT, IN a_get_first_order_only BIT, @@ -19,8 +19,8 @@ CREATE PROCEDURE p_shop_get_many_manufacturing_purchase_order ( IN a_ids_product VARCHAR(4000), IN a_get_inactive_permutation BIT, IN a_ids_permutation VARCHAR(4000), - IN a_date_from DATETIME, - IN a_date_to DATETIME + IN a_date_from TIMESTAMP, + IN a_date_to TIMESTAMP ) BEGIN -- Argument redeclaration @@ -31,14 +31,14 @@ BEGIN DECLARE v_has_filter_permutation BIT; DECLARE v_has_filter_date_from BIT; DECLARE v_has_filter_date_to BIT; - DECLARE v_guid VARCHAR(36); + DECLARE v_guid BINARY(36); # DECLARE v_id_user VARCHAR(100); # DECLARE v_ids_permutation_unavailable VARCHAR(4000); DECLARE v_ids_permission_manufacturing_purchase_order VARCHAR(4000); DECLARE v_ids_product_permission VARCHAR(4000); # DECLARE v_ids_permutation_permission VARCHAR(4000); DECLARE v_id_access_level_view INT; - -- DECLARE v_now DATETIME; + -- DECLARE v_now TIMESTAMP; -- DECLARE v_id_minimum INT; DECLARE v_code_error_data VARCHAR(50); DECLARE v_id_type_error_data INT; @@ -189,7 +189,7 @@ BEGIN CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, id_type INT NOT NULL, CONSTRAINT FK_tmp_Msg_Error_id_type FOREIGN KEY (id_type) diff --git a/static/MySQL/7421_p_shop_save_customer.sql b/static/MySQL/7421_p_shop_save_customer.sql index cdd095a8..7fce6bf7 100644 --- a/static/MySQL/7421_p_shop_save_customer.sql +++ b/static/MySQL/7421_p_shop_save_customer.sql @@ -9,7 +9,7 @@ DROP PROCEDURE IF EXISTS p_shop_save_customer; DELIMITER // CREATE PROCEDURE p_shop_save_customer ( IN a_guid VARCHAR(500), - IN a_id_user VARCHAR(200), + IN a_id_user INT, IN a_comment VARCHAR(500), IN a_id_customer INT, IN a_name_company VARCHAR(256), @@ -24,7 +24,7 @@ CREATE PROCEDURE p_shop_save_customer ( BEGIN DECLARE v_id_error_type_bad_data INT; DECLARE v_id_error_type_no_permission INT; - DECLARE v_guid_permission VARCHAR(36); + DECLARE v_guid_permission BINARY(36); DECLARE v_id_permission_customer INT; DECLARE v_id_access_level_EDIT INT; DECLARE v_has_permission BIT; @@ -70,7 +70,7 @@ BEGIN CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, id_type INT NOT NULL, CONSTRAINT FK_tmp_Msg_Error_id_type FOREIGN KEY (id_type) diff --git a/static/MySQL/7422_p_shop_get_many_customer.sql b/static/MySQL/7422_p_shop_get_many_customer.sql index 0740ba8c..1741a1fc 100644 --- a/static/MySQL/7422_p_shop_get_many_customer.sql +++ b/static/MySQL/7422_p_shop_get_many_customer.sql @@ -20,7 +20,7 @@ DROP PROCEDURE IF EXISTS p_shop_get_many_customer; DELIMITER // CREATE PROCEDURE p_shop_get_many_customer ( - IN a_id_user VARCHAR(200), + IN a_id_user INT, IN a_get_all_customer BIT, IN a_get_inactive_customer BIT, IN a_get_first_customer_only BIT, @@ -32,14 +32,14 @@ BEGIN DECLARE v_id_error_type_bad_data INT; DECLARE v_code_error_type_bad_data VARCHAR(50); DECLARE v_has_filter_customer BIT; - DECLARE v_guid VARCHAR(36); + DECLARE v_guid BINARY(36); # DECLARE v_id_user VARCHAR(100); # DECLARE v_ids_permutation_unavailable VARCHAR(4000); DECLARE v_id_permission_customer INT; # DECLARE v_ids_product_permission VARCHAR(4000); # DECLARE v_ids_permutation_permission VARCHAR(4000); DECLARE v_id_access_level_view INT; - DECLARE v_now DATETIME; + DECLARE v_now TIMESTAMP; DECLARE v_id_minimum INT; SET v_code_error_type_bad_data = 'BAD_DATA'; @@ -90,7 +90,7 @@ BEGIN CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, id_type INT NOT NULL, CONSTRAINT FK_tmp_Msg_Error_id_type FOREIGN KEY (id_type) diff --git a/static/MySQL/7424_p_shop_save_customer_sales_order.sql b/static/MySQL/7424_p_shop_save_customer_sales_order.sql index 16766a33..9c28c7cc 100644 --- a/static/MySQL/7424_p_shop_save_customer_sales_order.sql +++ b/static/MySQL/7424_p_shop_save_customer_sales_order.sql @@ -11,7 +11,7 @@ DROP TABLE IF EXISTS tmp_Msg_Error; DELIMITER // CREATE PROCEDURE p_shop_save_customer_sales_order ( IN a_guid VARCHAR(500), - IN a_id_user VARCHAR(200), + IN a_id_user INT, IN a_comment VARCHAR(500), IN a_id_order INT, IN a_id_customer INT, @@ -23,7 +23,7 @@ BEGIN 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 VARCHAR(36); + DECLARE v_guid_permission BINARY(36); -- DECLARE v_id_user VARCHAR(100); DECLARE v_id_permission_Customer_Sales_order INT; DECLARE v_id_access_level_EDIT INT; @@ -93,7 +93,7 @@ BEGIN CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, id_type INT NOT NULL, CONSTRAINT FK_tmp_Msg_Error_id_type FOREIGN KEY (id_type) diff --git a/static/MySQL/7425_p_shop_get_many_customer_sales_order.sql b/static/MySQL/7425_p_shop_get_many_customer_sales_order.sql index 4927facf..795828e6 100644 --- a/static/MySQL/7425_p_shop_get_many_customer_sales_order.sql +++ b/static/MySQL/7425_p_shop_get_many_customer_sales_order.sql @@ -8,7 +8,7 @@ DROP PROCEDURE IF EXISTS p_shop_get_many_customer_sales_order; DELIMITER // CREATE PROCEDURE p_shop_get_many_customer_sales_order ( - IN a_id_user VARCHAR(200), + IN a_id_user INT, IN a_get_all_customer BIT, IN a_get_inactive_customer BIT, IN a_get_first_customer_only BIT, @@ -23,8 +23,8 @@ CREATE PROCEDURE p_shop_get_many_customer_sales_order ( IN a_ids_product VARCHAR(4000), IN a_get_inactive_permutation BIT, IN a_ids_permutation VARCHAR(4000), - IN a_date_from DATETIME, - IN a_date_to DATETIME + IN a_date_from TIMESTAMP, + IN a_date_to TIMESTAMP ) BEGIN -- Argument redeclaration @@ -36,14 +36,14 @@ BEGIN DECLARE v_has_filter_permutation BIT; DECLARE v_has_filter_date_from BIT; DECLARE v_has_filter_date_to BIT; - DECLARE v_guid VARCHAR(36); + DECLARE v_guid BINARY(36); # DECLARE v_id_user VARCHAR(100); # DECLARE v_ids_permutation_unavailable VARCHAR(4000); DECLARE v_ids_permission_customer_purchase_order VARCHAR(4000); DECLARE v_ids_product_permission VARCHAR(4000); # DECLARE v_ids_permutation_permission VARCHAR(4000); DECLARE v_id_access_level_view INT; - -- DECLARE v_now DATETIME; + -- DECLARE v_now TIMESTAMP; -- DECLARE v_id_minimum INT; DECLARE v_code_error_data VARCHAR(50); DECLARE v_id_type_error_data INT; @@ -224,7 +224,7 @@ BEGIN CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, id_type INT NOT NULL, CONSTRAINT FK_tmp_Msg_Error_id_type FOREIGN KEY (id_type) diff --git a/static/MySQL/9000_populate.sql b/static/MySQL/9000_populate.sql index 31f92826..25717cb6 100644 --- a/static/MySQL/9000_populate.sql +++ b/static/MySQL/9000_populate.sql @@ -545,6 +545,7 @@ VALUES (1, 'HOME', 'Home Page', 2, 1), (2, 'STORE_PRODUCT', 'Store Product Page', 3, 1), (3, 'STORE_USER', 'Store User Account Page', 4, 2), + (10, 'STORE_USER_ADMIN', 'Store User Admin Page', 4, 3), (4, 'STORE_ADMIN', 'Store Admin Page', 1, 3), (5, 'STORE_SUPPLIER', 'Store Supplier Page', 4, 2), (6, 'STORE_SUPPLIER_PURCHASE_ORDER', 'Store Supplier Purchase Order Page', 4, 2), @@ -584,15 +585,16 @@ VALUES # Users INSERT INTO Shop_User ( - id_user, - name, - email, - # email_verified, - is_super_user + id_user_auth0 + , firstname + , surname + , email + # email_verified + , is_super_user ) VALUES - ('auth0|6582b95c895d09a70ba10fef', 'Teddy', 'edward.middletonsmith@gmail.com', 1), - ('parts_guest', 'Guest', '', 0) + ('auth0|6582b95c895d09a70ba10fef', 'Teddy', 'Middleton-Smith', 'edward.middletonsmith@gmail.com', 1), + ('parts_guest', 'Guest', '', '', 0) ; # User Role link @@ -600,14 +602,14 @@ INSERT INTO Shop_User_Role_Link ( id_user, id_role ) VALUES - ('auth0|6582b95c895d09a70ba10fef', 1) + (1, 1) ; # Addresses INSERT INTO Shop_Address ( id_user, id_region, name_full, phone_number, postcode, address_line_1, address_line_2, city, county ) -SELECT U.id_user, 1, U.name, '07375 571430', 'CV22 6DN', '53 Alfred Green Close', '', 'Rugby', 'Warwickshire' +SELECT U.id_user, 1, CONCAT(U.firstname, ' ', U.surname), '07375 571430', 'CV22 6DN', '53 Alfred Green Close', '', 'Rugby', 'Warwickshire' FROM Shop_User U ; @@ -619,7 +621,7 @@ INSERT INTO Shop_User_Basket ( quantity ) VALUES - ('auth0|6582b95c895d09a70ba10fef', 1, 1, 69) + (1, 1, 1, 69) ; # User Order Status @@ -637,8 +639,8 @@ INSERT INTO Shop_User_Order ( id_user, value_total, id_order_status, id_checkout_session, id_currency ) VALUES - ('auth0|6582b95c895d09a70ba10fef', 25, 1, 'noods', 1), - ('auth0|6582b95c895d09a70ba10fef', 25, 1, 'noods', 1) + (1, 25, 1, 'noods', 1), + (1, 25, 1, 'noods', 1) ; # User Order Product Link diff --git a/static/MySQL/9010_anal.sql b/static/MySQL/9010_anal.sql index 90b4d9ff..389b6f46 100644 --- a/static/MySQL/9010_anal.sql +++ b/static/MySQL/9010_anal.sql @@ -23,4 +23,5 @@ FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'PARTS' - -- AND TABLE_NAME = 'your_table_name'; + -- AND TABLE_NAME = 'your_table_name' +; \ No newline at end of file diff --git a/static/MySQL/deprecated/000_init_tables_authentication.sql b/static/MySQL/deprecated/000_init_tables_authentication.sql index 482888a6..65ab830e 100644 --- a/static/MySQL/deprecated/000_init_tables_authentication.sql +++ b/static/MySQL/deprecated/000_init_tables_authentication.sql @@ -38,7 +38,7 @@ DROP TABLE IF EXISTS Shop_User_Change_Set; CREATE TABLE Shop_User_Change_Set ( id_change_set INT NOT NULL AUTO_INCREMENT PRIMARY KEY, comment VARCHAR(500), - updated_last_on DATETIME, + updated_last_on TIMESTAMP, updated_last_by VARCHAR(100) ); @@ -68,7 +68,7 @@ CREATE TABLE Shop_Access_Level ( priority INT NOT NULL, active BIT NOT NULL DEFAULT 1, display_order INT NOT NULL, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Access_Level_id_change_set @@ -158,7 +158,7 @@ CREATE TABLE Shop_Permission_Group ( name VARCHAR(255), active BIT NOT NULL DEFAULT 1, display_order INT NOT NULL, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Permission_Group_id_change_set @@ -253,7 +253,7 @@ CREATE TABLE Shop_Permission ( REFERENCES Shop_Access_Level(id_access_level), active BIT NOT NULL DEFAULT 1, display_order INT NOT NULL, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Permission_id_change_set @@ -348,7 +348,7 @@ CREATE TABLE Shop_Role ( name VARCHAR(255), active BIT NOT NULL DEFAULT 1, display_order INT NOT NULL, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Role_id_change_set @@ -448,7 +448,7 @@ CREATE TABLE Shop_Role_Permission_Link ( REFERENCES Shop_Access_Level(id_access_level) ON UPDATE RESTRICT, active BIT NOT NULL DEFAULT 1, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Role_Permission_Link_id_change_set @@ -541,7 +541,7 @@ CREATE TABLE Shop_User ( name VARCHAR(255), is_super_user BIT NOT NULL DEFAULT 0, active BIT NOT NULL DEFAULT 1, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_User_id_change_set @@ -635,7 +635,7 @@ CREATE TABLE Shop_User_Role_Link ( REFERENCES Shop_Role(id_role) ON UPDATE RESTRICT, active BIT NOT NULL DEFAULT 1, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_User_Role_Link_id_change_set @@ -722,7 +722,7 @@ CREATE TABLE Shop_Address ( city VARCHAR(50) NOT NULL, county VARCHAR(100) NOT NULL, active BIT NOT NULL DEFAULT 1, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Address_id_change_set diff --git a/static/MySQL/deprecated/000_init_tables_product.sql b/static/MySQL/deprecated/000_init_tables_product.sql index 66b726ad..6f16be31 100644 --- a/static/MySQL/deprecated/000_init_tables_product.sql +++ b/static/MySQL/deprecated/000_init_tables_product.sql @@ -56,7 +56,7 @@ DROP TABLE IF EXISTS Shop_Product_Change_Set; CREATE TABLE Shop_Product_Change_Set ( id_change_set INT NOT NULL AUTO_INCREMENT PRIMARY KEY, comment VARCHAR(500), - updated_last_on DATETIME, + updated_last_on TIMESTAMP, updated_last_by VARCHAR(100) ); @@ -84,9 +84,9 @@ CREATE TABLE File_Type ( code VARCHAR(50), name VARCHAR(100), extension VARCHAR(50), - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), - updated_last_on DATETIME, + updated_last_on TIMESTAMP, updated_last_by VARCHAR(100) ); @@ -110,9 +110,9 @@ CREATE TABLE File_Type_Audit ( name_field VARCHAR(50), value_prev VARCHAR(500), value_new VARCHAR(500), - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), - updated_last_on DATETIME, + updated_last_on TIMESTAMP, updated_last_by VARCHAR(100) ); @@ -181,7 +181,7 @@ SELECT * FROM File_Type_Audit; CREATE TABLE Shop_General ( id_general INT NOT NULL AUTO_INCREMENT PRIMARY KEY, quantity_max FLOAT, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_General_id_change_set @@ -254,7 +254,7 @@ CREATE TABLE Shop_Category ( description VARCHAR(4000), active BIT NOT NULL DEFAULT 1, display_order INT NOT NULL, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Category_id_change_set @@ -347,7 +347,7 @@ CREATE TABLE Shop_Recurrence_Interval ( code VARCHAR(50), name VARCHAR(255), name_plural VARCHAR(256), - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Recurrence_Interval_id_change_set @@ -448,7 +448,7 @@ CREATE TABLE Shop_Product ( id_stripe_price VARCHAR(100), active BIT NOT NULL DEFAULT 1, display_order INT NOT NULL, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Product_id_change_set @@ -597,7 +597,7 @@ CREATE TABLE Shop_Variation_Type ( name_plural VARCHAR(256), active BIT NOT NULL DEFAULT 1, display_order INT NOT NULL, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Variation_Type_id_change_set @@ -690,7 +690,7 @@ CREATE TABLE Shop_Variation ( name VARCHAR(255), active BIT NOT NULL DEFAULT 1, display_order INT NOT NULL, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Variation_id_change_set @@ -782,7 +782,7 @@ CREATE TABLE Shop_Product_Variation_Link ( ON UPDATE RESTRICT, active BIT NOT NULL DEFAULT 1, display_order INT NOT NULL, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Product_Variation_Link_id_change_set @@ -872,7 +872,7 @@ CREATE TABLE Shop_Image_Type ( name_plural VARCHAR(256), active BIT NOT NULL DEFAULT 1, display_order INT NOT NULL, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Image_Type_id_change_set @@ -969,7 +969,7 @@ CREATE TABLE Shop_Image ( url VARCHAR(255), active BIT NOT NULL DEFAULT 1, display_order INT NOT NULL, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Image_id_change_set @@ -1063,7 +1063,7 @@ CREATE TABLE Shop_Product_Image_Link ( REFERENCES Shop_Image(id_image) ON UPDATE RESTRICT, active BIT NOT NULL DEFAULT 1, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Product_Image_Link_id_change_set @@ -1154,7 +1154,7 @@ CREATE TABLE Shop_Delivery_Option_Type ( quantity_max INT NOT NULL, active BIT NOT NULL DEFAULT 1, display_order INT NOT NULL, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Delivery_Option_Type_id_change_set @@ -1263,7 +1263,7 @@ CREATE TABLE Shop_Delivery_Option ( ON UPDATE RESTRICT, price_GBP FLOAT NOT NULL, active BIT NOT NULL DEFAULT 1, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Delivery_Option_id_change_set @@ -1352,7 +1352,7 @@ CREATE TABLE Shop_Delivery_Region ( name VARCHAR(200) NOT NULL, active BIT NOT NULL DEFAULT 1, display_order INT NOT NULL, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Delivery_Region_id_change_set @@ -1443,7 +1443,7 @@ CREATE TABLE Shop_Product_Delivery_Region_Link ( REFERENCES Shop_Delivery_Region(id_region) ON UPDATE RESTRICT, active BIT NOT NULL DEFAULT 1, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Product_Delivery_Region_Link_id_change_set diff --git a/static/MySQL/deprecated/108_tbl_Shop_Recurrence_Interval.sql b/static/MySQL/deprecated/108_tbl_Shop_Recurrence_Interval.sql index 3cac1d05..72f4ad69 100644 --- a/static/MySQL/deprecated/108_tbl_Shop_Recurrence_Interval.sql +++ b/static/MySQL/deprecated/108_tbl_Shop_Recurrence_Interval.sql @@ -11,7 +11,7 @@ CREATE TABLE IF NOT EXISTS Shop_Recurrence_Interval ( name VARCHAR(255), name_plural VARCHAR(256), active BIT NOT NULL DEFAULT 1, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Recurrence_Interval_id_change_set diff --git a/static/MySQL/deprecated/113.1_tbl_Shop_Product_Variation_Type_Link.sql b/static/MySQL/deprecated/113.1_tbl_Shop_Product_Variation_Type_Link.sql index 5e76060a..917fa642 100644 --- a/static/MySQL/deprecated/113.1_tbl_Shop_Product_Variation_Type_Link.sql +++ b/static/MySQL/deprecated/113.1_tbl_Shop_Product_Variation_Type_Link.sql @@ -19,7 +19,7 @@ CREATE TABLE IF NOT EXISTS Shop_Product_Variation_Type_Link ( ON UPDATE RESTRICT, active BIT NOT NULL DEFAULT 1, display_order INT NOT NULL, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Product_Variation_Type_Link_id_change_set diff --git a/static/MySQL/deprecated/116_tbl_Shop_Product_Variation_Link.sql b/static/MySQL/deprecated/116_tbl_Shop_Product_Variation_Link.sql index 64527ca8..3831857c 100644 --- a/static/MySQL/deprecated/116_tbl_Shop_Product_Variation_Link.sql +++ b/static/MySQL/deprecated/116_tbl_Shop_Product_Variation_Link.sql @@ -26,7 +26,7 @@ CREATE TABLE IF NOT EXISTS Shop_Product_Variation_Link ( */ active BIT NOT NULL DEFAULT 1, display_order INT NOT NULL, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Product_Variation_Link_id_change_set diff --git a/static/MySQL/deprecated/128_tbl_Shop_Product_Delivery_Region_Link.sql b/static/MySQL/deprecated/128_tbl_Shop_Product_Delivery_Region_Link.sql index 6280c3c3..ccbd9da4 100644 --- a/static/MySQL/deprecated/128_tbl_Shop_Product_Delivery_Region_Link.sql +++ b/static/MySQL/deprecated/128_tbl_Shop_Product_Delivery_Region_Link.sql @@ -23,7 +23,7 @@ CREATE TABLE IF NOT EXISTS Shop_Product_Delivery_Region_Link ( REFERENCES Shop_Delivery_Region(id_region) ON UPDATE RESTRICT, active BIT NOT NULL DEFAULT 1, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_Product_Delivery_Region_Link_id_change_set diff --git a/static/MySQL/deprecated/170_ish_tbl_ERP_Order.sql b/static/MySQL/deprecated/170_ish_tbl_ERP_Order.sql index 072fc3c5..bc4aa33a 100644 --- a/static/MySQL/deprecated/170_ish_tbl_ERP_Order.sql +++ b/static/MySQL/deprecated/170_ish_tbl_ERP_Order.sql @@ -10,7 +10,7 @@ CREATE TABLE IF NOT EXISTS ERP_Order ( code VARCHAR(50), name VARCHAR(100), extension VARCHAR(50), - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_customer INT NOT NULL, CONSTRAINT FK_ERP_Order_id_customer diff --git a/static/MySQL/deprecated/171_tbl_Shop_User_Order.sql b/static/MySQL/deprecated/171_tbl_Shop_User_Order.sql index f8d5c25c..e7dbcd23 100644 --- a/static/MySQL/deprecated/171_tbl_Shop_User_Order.sql +++ b/static/MySQL/deprecated/171_tbl_Shop_User_Order.sql @@ -7,7 +7,7 @@ SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning CREATE TABLE IF NOT EXISTS Shop_User_Order ( id_order INT NOT NULL AUTO_INCREMENT PRIMARY KEY, - id_user VARCHAR(200) NOT NULL, + id_user INT NOT NULL, CONSTRAINT FK_Shop_User_Order_id_user FOREIGN KEY (id_user) REFERENCES Shop_User(id_user) @@ -24,7 +24,7 @@ CREATE TABLE IF NOT EXISTS Shop_User_Order ( REFERENCES Shop_Currency(id_currency) ON UPDATE RESTRICT, active BIT NOT NULL DEFAULT 1, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set_user INT, CONSTRAINT FK_Shop_User_Order_id_change_set_user diff --git a/static/MySQL/deprecated/173_tbl_Shop_User_Order_Product_Link.sql b/static/MySQL/deprecated/173_tbl_Shop_User_Order_Product_Link.sql index dacc9cc1..a7f741c8 100644 --- a/static/MySQL/deprecated/173_tbl_Shop_User_Order_Product_Link.sql +++ b/static/MySQL/deprecated/173_tbl_Shop_User_Order_Product_Link.sql @@ -24,7 +24,7 @@ CREATE TABLE IF NOT EXISTS Shop_User_Order_Product_Link ( ON UPDATE RESTRICT, quantity FLOAT NOT NULL, active BIT NOT NULL DEFAULT 1, - created_on DATETIME, + created_on TIMESTAMP, created_by VARCHAR(100), id_change_set INT, CONSTRAINT FK_Shop_User_Order_Product_Link_id_change_set diff --git a/static/MySQL/deprecated/7000_p_shop_get_many_role_permission.sql b/static/MySQL/deprecated/7000_p_shop_get_many_role_permission.sql index b4ede970..36f6fc03 100644 --- a/static/MySQL/deprecated/7000_p_shop_get_many_role_permission.sql +++ b/static/MySQL/deprecated/7000_p_shop_get_many_role_permission.sql @@ -42,7 +42,7 @@ BEGIN DECLARE v_priority_admin INT; /* DECLARE v_ids_product_permission VARCHAR(500); - DECLARE v_now DATETIME; + DECLARE v_now TIMESTAMP; */ -- Parse arguments + get default values diff --git a/static/MySQL/deprecated/7000_p_shop_get_many_user_order.sql b/static/MySQL/deprecated/7000_p_shop_get_many_user_order.sql index c06c5d17..112d6f06 100644 --- a/static/MySQL/deprecated/7000_p_shop_get_many_user_order.sql +++ b/static/MySQL/deprecated/7000_p_shop_get_many_user_order.sql @@ -19,7 +19,7 @@ DROP PROCEDURE IF EXISTS p_shop_get_many_user_order; DELIMITER // CREATE PROCEDURE p_shop_get_many_user_order ( - IN a_id_user VARCHAR(200), + IN a_id_user INT, IN a_ids_order VARCHAR(4000), IN a_n_order_max INT, IN a_id_checkout_session VARCHAR(200) @@ -32,7 +32,7 @@ BEGIN DECLARE v_has_filter_session BIT; DECLARE v_code_error_data VARCHAR(200); DECLARE v_code_error_permission VARCHAR(200); - DECLARE v_guid VARCHAR(36); + DECLARE v_guid BINARY(36); SET v_code_error_data := (SELECT code FROM Shop_Msg_Error_Type WHERE id_type = 1); SET v_code_error_permission := (SELECT code FROM Shop_Msg_Error_Type WHERE id_type = 2); @@ -65,7 +65,7 @@ BEGIN DROP TABLE IF EXISTS tmp_Shop_Order; CREATE TABLE tmp_Shop_User( - id_user VARCHAR(200) NOT NULL PRIMARY KEY, + id_user INT NOT NULL PRIMARY KEY, CONSTRAINT FK_tmp_Shop_User_id_user FOREIGN KEY (id_user) REFERENCES Shop_User(id_user), @@ -82,7 +82,7 @@ BEGIN CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + 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), diff --git a/static/MySQL/deprecated/706_p_shop_get_product.sql b/static/MySQL/deprecated/706_p_shop_get_product.sql index 08cbc33d..b2903189 100644 --- a/static/MySQL/deprecated/706_p_shop_get_product.sql +++ b/static/MySQL/deprecated/706_p_shop_get_product.sql @@ -20,7 +20,7 @@ DROP PROCEDURE IF EXISTS p_shop_get_product; DELIMITER // CREATE PROCEDURE p_shop_get_product ( - IN a_id_user VARCHAR(200), + IN a_id_user INT, IN a_id_product INT, IN a_ids_permutation VARCHAR(4000), IN a_ids_image VARCHAR(500), @@ -34,13 +34,13 @@ BEGIN DECLARE v_id_product_search VARCHAR(10); DECLARE v_has_filter_permutation BIT; DECLARE v_has_product_permutations BIT; - DECLARE v_guid VARCHAR(36); + DECLARE v_guid BINARY(36); # DECLARE v_id_user VARCHAR(100); DECLARE v_id_permission_product INT; DECLARE v_ids_product_permission VARCHAR(500); DECLARE v_id_access_level_view INT; DECLARE v_has_filter_image BIT; - DECLARE v_now DATETIME; + DECLARE v_now TIMESTAMP; DECLARE v_id_minimum INT; DECLARE v_code_error_data VARCHAR(50); @@ -112,7 +112,7 @@ BEGIN CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, # code VARCHAR(50) NOT NULL, # CONSTRAINT chk_tmp_Msg_Error_code CHECK (code IN (SELECT code FROM Shop_Msg_Error_Type)), id_type INT NOT NULL, diff --git a/static/MySQL/deprecated/dump.sql b/static/MySQL/deprecated/dump.sql index b835b0ef..c1965e2a 100644 --- a/static/MySQL/deprecated/dump.sql +++ b/static/MySQL/deprecated/dump.sql @@ -4952,7 +4952,7 @@ UNLOCK TABLES; /*!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 ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `p_shop_edit_user`( - IN a_id_user VARCHAR(200), + IN a_id_user INT, IN a_name VARCHAR(255), IN a_email VARCHAR(254), IN a_email_verified BIT @@ -4961,7 +4961,7 @@ BEGIN -- Argument redeclaration -- Variable declaration DECLARE v_has_filter_user BIT; - -- DECLARE v_now DATETIME; + -- DECLARE v_now TIMESTAMP; -- Argument validation + default values @@ -4989,7 +4989,7 @@ BEGIN DROP TABLE IF EXISTS tmp_Shop_User; CREATE TABLE tmp_Shop_User ( - id_user VARCHAR(200) NOT NULL, + id_user INT NOT NULL, CONSTRAINT FK_tmp_Shop_User_id_user FOREIGN KEY (id_user) REFERENCES Shop_User(id_user), @@ -5113,7 +5113,7 @@ DELIMITER ; /*!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 ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `p_shop_edit_user_basket`( - IN a_id_user VARCHAR(200), + IN a_id_user INT, IN a_ids_permutation_basket VARCHAR(4000), IN a_quantities_permutation_basket VARCHAR(4000), IN a_id_permutation_edit INT, @@ -5133,11 +5133,11 @@ BEGIN DECLARE v_n_id_permutation_basket INT; DECLARE v_n_quantity_permutation_basket INT; DECLARE v_row_number INT; - DECLARE v_guid VARCHAR(36); + DECLARE v_guid BINARY(36); # DECLARE v_id_user VARCHAR(100); DECLARE v_id_permission_product INT; DECLARE v_ids_permutation_permission VARCHAR(4000); - DECLARE v_now DATETIME; + DECLARE v_now TIMESTAMP; # DECLARE v_quantity_new INT; DECLARE v_change_set_used BIT; DECLARE v_id_change_set INT; @@ -5172,7 +5172,7 @@ BEGIN DROP TABLE IF EXISTS tmp_Shop_User; CREATE TABLE tmp_Shop_User ( - id_user VARCHAR(200) NOT NULL, + id_user INT NOT NULL, CONSTRAINT FK_tmp_Shop_User_id_user FOREIGN KEY (id_user) REFERENCES Shop_User(id_user), @@ -5229,7 +5229,7 @@ BEGIN CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, id_type INT NOT NULL, # code VARCHAR(50) NOT NULL, # CONSTRAINT chk_tmp_Msg_Error_code CHECK (code IN (SELECT code FROM Shop_Msg_Error_Type)), @@ -5914,7 +5914,7 @@ DELIMITER ; /*!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 ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `p_shop_get_many_product`( - IN a_id_user VARCHAR(200), + IN a_id_user INT, IN a_get_all_category BIT, IN a_ids_category VARCHAR(500), IN a_get_inactive_category BIT, @@ -5949,14 +5949,14 @@ BEGIN DECLARE v_has_filter_delivery_region BIT; DECLARE v_has_filter_currency BIT; DECLARE v_has_filter_discount BIT; - DECLARE v_guid VARCHAR(36); + DECLARE v_guid BINARY(36); # DECLARE v_id_user VARCHAR(100); DECLARE v_ids_permutation_unavailable VARCHAR(4000); DECLARE v_id_permission_product INT; DECLARE v_ids_product_permission VARCHAR(4000); DECLARE v_ids_permutation_permission VARCHAR(4000); DECLARE v_id_access_level_view INT; - DECLARE v_now DATETIME; + DECLARE v_now TIMESTAMP; DECLARE v_id_minimum INT; SET v_guid := UUID(); @@ -6184,7 +6184,7 @@ BEGIN CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( # IF NOT EXISTS display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, # code VARCHAR(50) NOT NULL, # CONSTRAINT chk_tmp_Msg_Error_code CHECK (code IN (SELECT code FROM Shop_Msg_Error_Type)), id_type INT NOT NULL, @@ -7027,13 +7027,13 @@ DELIMITER ; /*!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 ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `p_shop_get_many_stripe_price_new`( - IN a_id_user VARCHAR(200) + IN a_id_user INT ) BEGIN DECLARE v_has_filter_user BIT; DECLARE v_code_error_data VARCHAR(200); DECLARE v_code_error_permission VARCHAR(200); - DECLARE v_guid VARCHAR(36); + DECLARE v_guid BINARY(36); SET v_code_error_data := (SELECT code FROM Shop_Msg_Error_Type WHERE id_type = 1); SET v_code_error_permission := (SELECT code FROM Shop_Msg_Error_Type WHERE id_type = 2); @@ -7054,7 +7054,7 @@ BEGIN DROP TABLE IF EXISTS tmp_Shop_User; CREATE TABLE tmp_Shop_User( - id_user VARCHAR(200) NOT NULL PRIMARY KEY, + id_user INT NOT NULL PRIMARY KEY, CONSTRAINT FK_tmp_Shop_User_id_user FOREIGN KEY (id_user) REFERENCES Shop_User(id_user), @@ -7083,7 +7083,7 @@ BEGIN CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( # IF NOT EXISTS display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, code VARCHAR(50) NOT NULL, # CONSTRAINT chk_tmp_Msg_Error_code CHECK (code IN (SELECT code FROM Shop_Msg_Error_Type)), /* @@ -7255,13 +7255,13 @@ DELIMITER ; /*!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 ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `p_shop_get_many_stripe_product_new`( - IN a_id_user VARCHAR(200) + IN a_id_user INT ) BEGIN DECLARE v_has_filter_user BIT; DECLARE v_code_error_data VARCHAR(200); DECLARE v_code_error_permission VARCHAR(200); - DECLARE v_guid VARCHAR(36); + DECLARE v_guid BINARY(36); SET v_code_error_data := (SELECT code FROM Shop_Msg_Error_Type WHERE id_type = 1); SET v_code_error_permission := (SELECT code FROM Shop_Msg_Error_Type WHERE id_type = 2); @@ -7281,7 +7281,7 @@ BEGIN DROP TABLE IF EXISTS tmp_Shop_User; CREATE TABLE tmp_Shop_User( - id_user VARCHAR(200) NOT NULL PRIMARY KEY, + id_user INT NOT NULL PRIMARY KEY, CONSTRAINT FK_tmp_Shop_User_id_user FOREIGN KEY (id_user) REFERENCES Shop_User(id_user), @@ -7306,7 +7306,7 @@ BEGIN CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( # IF NOT EXISTS display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, code VARCHAR(50) NOT NULL, # CONSTRAINT chk_tmp_Msg_Error_code CHECK (code IN (SELECT code FROM Shop_Msg_Error_Type)), /* @@ -7532,7 +7532,7 @@ DELIMITER ; /*!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 ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `p_shop_get_many_user_order`( - IN a_id_user VARCHAR(200), + IN a_id_user INT, IN a_ids_order VARCHAR(4000), IN a_n_order_max INT, IN a_id_checkout_session VARCHAR(200) @@ -7545,7 +7545,7 @@ BEGIN DECLARE v_has_filter_session BIT; DECLARE v_code_error_data VARCHAR(200); DECLARE v_code_error_permission VARCHAR(200); - DECLARE v_guid VARCHAR(36); + DECLARE v_guid BINARY(36); SET v_code_error_data := (SELECT code FROM Shop_Msg_Error_Type WHERE id_type = 1); SET v_code_error_permission := (SELECT code FROM Shop_Msg_Error_Type WHERE id_type = 2); @@ -7578,7 +7578,7 @@ BEGIN DROP TABLE IF EXISTS tmp_Shop_Order; CREATE TABLE tmp_Shop_User( - id_user VARCHAR(200) NOT NULL PRIMARY KEY, + id_user INT NOT NULL PRIMARY KEY, CONSTRAINT FK_tmp_Shop_User_id_user FOREIGN KEY (id_user) REFERENCES Shop_User(id_user), @@ -7595,7 +7595,7 @@ BEGIN CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + 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), @@ -7784,8 +7784,8 @@ DELIMITER ; /*!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 ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `p_shop_user_eval`( - IN a_guid VARCHAR(36), - IN a_id_user VARCHAR(200), + IN a_guid BINARY(36), + IN a_id_user INT, IN a_get_inactive_users BIT, IN a_ids_permission VARCHAR(500), IN a_ids_access_level VARCHAR(100), @@ -7807,7 +7807,7 @@ BEGIN DECLARE v_priority_access_level_admin INT; DECLARE v_id_access_level INT; DECLARE v_priority_access_level INT; - DECLARE v_now DATETIME; + DECLARE v_now TIMESTAMP; DECLARE v_ids_row_delete VARCHAR(500); DECLARE v_code_error_data VARCHAR(200); DECLARE v_id_error_data INT; @@ -7863,8 +7863,8 @@ BEGIN -- Permanent Table CREATE TABLE IF NOT EXISTS Shop_User_Eval_Temp ( id_row INT PRIMARY KEY AUTO_INCREMENT NOT NULL, - guid VARCHAR(36) NOT NULL, - id_user VARCHAR(200), + guid BINARY(36) NOT NULL, + id_user INT, id_permission_required INT NOT NULL, CONSTRAINT FK_Shop_User_Eval_Temp_id_permission_required FOREIGN KEY (id_permission_required) @@ -7912,13 +7912,13 @@ BEGIN id_access_level_required INT NOT NULL, CONSTRAINT FK_tmp_Shop_Product_p_Shop_User_Eval_id_access_level_required FOREIGN KEY (id_access_level_required) REFERENCES Shop_Access_Level (id_access_level), - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, rank_permutation INT NOT NULL ); CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, id_type INT NOT NULL, CONSTRAINT FK_tmp_Msg_Error_id_type FOREIGN KEY (id_type) diff --git a/static/MySQL/deprecated/dump2.sql b/static/MySQL/deprecated/dump2.sql index f4e520f8..fe13121f 100644 --- a/static/MySQL/deprecated/dump2.sql +++ b/static/MySQL/deprecated/dump2.sql @@ -4952,7 +4952,7 @@ UNLOCK TABLES; /*!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 ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `p_shop_edit_user`( - IN a_id_user VARCHAR(200), + IN a_id_user INT, IN a_name VARCHAR(255), IN a_email VARCHAR(254), IN a_email_verified BIT @@ -4961,7 +4961,7 @@ BEGIN -- Argument redeclaration -- Variable declaration DECLARE v_has_filter_user BIT; - -- DECLARE v_now DATETIME; + -- DECLARE v_now TIMESTAMP; -- Argument validation + default values @@ -4989,7 +4989,7 @@ BEGIN DROP TABLE IF EXISTS tmp_Shop_User; CREATE TABLE tmp_Shop_User ( - id_user VARCHAR(200) NOT NULL, + id_user INT NOT NULL, CONSTRAINT FK_tmp_Shop_User_id_user FOREIGN KEY (id_user) REFERENCES Shop_User(id_user), @@ -5113,7 +5113,7 @@ DELIMITER ; /*!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 ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `p_shop_edit_user_basket`( - IN a_id_user VARCHAR(200), + IN a_id_user INT, IN a_ids_permutation_basket VARCHAR(4000), IN a_quantities_permutation_basket VARCHAR(4000), IN a_id_permutation_edit INT, @@ -5133,11 +5133,11 @@ BEGIN DECLARE v_n_id_permutation_basket INT; DECLARE v_n_quantity_permutation_basket INT; DECLARE v_row_number INT; - DECLARE v_guid VARCHAR(36); + DECLARE v_guid BINARY(36); # DECLARE v_id_user VARCHAR(100); DECLARE v_id_permission_product INT; DECLARE v_ids_permutation_permission VARCHAR(4000); - DECLARE v_now DATETIME; + DECLARE v_now TIMESTAMP; # DECLARE v_quantity_new INT; DECLARE v_change_set_used BIT; DECLARE v_id_change_set INT; @@ -5172,7 +5172,7 @@ BEGIN DROP TABLE IF EXISTS tmp_Shop_User; CREATE TABLE tmp_Shop_User ( - id_user VARCHAR(200) NOT NULL, + id_user INT NOT NULL, CONSTRAINT FK_tmp_Shop_User_id_user FOREIGN KEY (id_user) REFERENCES Shop_User(id_user), @@ -5229,7 +5229,7 @@ BEGIN CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, id_type INT NOT NULL, # code VARCHAR(50) NOT NULL, # CONSTRAINT chk_tmp_Msg_Error_code CHECK (code IN (SELECT code FROM Shop_Msg_Error_Type)), @@ -5914,7 +5914,7 @@ DELIMITER ; /*!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 ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `p_shop_get_many_product`( - IN a_id_user VARCHAR(200), + IN a_id_user INT, IN a_get_all_category BIT, IN a_ids_category VARCHAR(500), IN a_get_inactive_category BIT, @@ -5949,14 +5949,14 @@ BEGIN DECLARE v_has_filter_delivery_region BIT; DECLARE v_has_filter_currency BIT; DECLARE v_has_filter_discount BIT; - DECLARE v_guid VARCHAR(36); + DECLARE v_guid BINARY(36); # DECLARE v_id_user VARCHAR(100); DECLARE v_ids_permutation_unavailable VARCHAR(4000); DECLARE v_id_permission_product INT; DECLARE v_ids_product_permission VARCHAR(4000); DECLARE v_ids_permutation_permission VARCHAR(4000); DECLARE v_id_access_level_view INT; - DECLARE v_now DATETIME; + DECLARE v_now TIMESTAMP; DECLARE v_id_minimum INT; SET v_guid := UUID(); @@ -6184,7 +6184,7 @@ BEGIN CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( # IF NOT EXISTS display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, # code VARCHAR(50) NOT NULL, # CONSTRAINT chk_tmp_Msg_Error_code CHECK (code IN (SELECT code FROM Shop_Msg_Error_Type)), id_type INT NOT NULL, @@ -7027,13 +7027,13 @@ DELIMITER ; /*!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 ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `p_shop_get_many_stripe_price_new`( - IN a_id_user VARCHAR(200) + IN a_id_user INT ) BEGIN DECLARE v_has_filter_user BIT; DECLARE v_code_error_data VARCHAR(200); DECLARE v_code_error_permission VARCHAR(200); - DECLARE v_guid VARCHAR(36); + DECLARE v_guid BINARY(36); SET v_code_error_data := (SELECT code FROM Shop_Msg_Error_Type WHERE id_type = 1); SET v_code_error_permission := (SELECT code FROM Shop_Msg_Error_Type WHERE id_type = 2); @@ -7054,7 +7054,7 @@ BEGIN DROP TABLE IF EXISTS tmp_Shop_User; CREATE TABLE tmp_Shop_User( - id_user VARCHAR(200) NOT NULL PRIMARY KEY, + id_user INT NOT NULL PRIMARY KEY, CONSTRAINT FK_tmp_Shop_User_id_user FOREIGN KEY (id_user) REFERENCES Shop_User(id_user), @@ -7083,7 +7083,7 @@ BEGIN CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( # IF NOT EXISTS display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, code VARCHAR(50) NOT NULL, # CONSTRAINT chk_tmp_Msg_Error_code CHECK (code IN (SELECT code FROM Shop_Msg_Error_Type)), /* @@ -7255,13 +7255,13 @@ DELIMITER ; /*!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 ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `p_shop_get_many_stripe_product_new`( - IN a_id_user VARCHAR(200) + IN a_id_user INT ) BEGIN DECLARE v_has_filter_user BIT; DECLARE v_code_error_data VARCHAR(200); DECLARE v_code_error_permission VARCHAR(200); - DECLARE v_guid VARCHAR(36); + DECLARE v_guid BINARY(36); SET v_code_error_data := (SELECT code FROM Shop_Msg_Error_Type WHERE id_type = 1); SET v_code_error_permission := (SELECT code FROM Shop_Msg_Error_Type WHERE id_type = 2); @@ -7281,7 +7281,7 @@ BEGIN DROP TABLE IF EXISTS tmp_Shop_User; CREATE TABLE tmp_Shop_User( - id_user VARCHAR(200) NOT NULL PRIMARY KEY, + id_user INT NOT NULL PRIMARY KEY, CONSTRAINT FK_tmp_Shop_User_id_user FOREIGN KEY (id_user) REFERENCES Shop_User(id_user), @@ -7306,7 +7306,7 @@ BEGIN CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( # IF NOT EXISTS display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, code VARCHAR(50) NOT NULL, # CONSTRAINT chk_tmp_Msg_Error_code CHECK (code IN (SELECT code FROM Shop_Msg_Error_Type)), /* @@ -7532,7 +7532,7 @@ DELIMITER ; /*!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 ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `p_shop_get_many_user_order`( - IN a_id_user VARCHAR(200), + IN a_id_user INT, IN a_ids_order VARCHAR(4000), IN a_n_order_max INT, IN a_id_checkout_session VARCHAR(200) @@ -7545,7 +7545,7 @@ BEGIN DECLARE v_has_filter_session BIT; DECLARE v_code_error_data VARCHAR(200); DECLARE v_code_error_permission VARCHAR(200); - DECLARE v_guid VARCHAR(36); + DECLARE v_guid BINARY(36); SET v_code_error_data := (SELECT code FROM Shop_Msg_Error_Type WHERE id_type = 1); SET v_code_error_permission := (SELECT code FROM Shop_Msg_Error_Type WHERE id_type = 2); @@ -7578,7 +7578,7 @@ BEGIN DROP TABLE IF EXISTS tmp_Shop_Order; CREATE TABLE tmp_Shop_User( - id_user VARCHAR(200) NOT NULL PRIMARY KEY, + id_user INT NOT NULL PRIMARY KEY, CONSTRAINT FK_tmp_Shop_User_id_user FOREIGN KEY (id_user) REFERENCES Shop_User(id_user), @@ -7595,7 +7595,7 @@ BEGIN CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + 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), @@ -7784,8 +7784,8 @@ DELIMITER ; /*!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 ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `p_shop_user_eval`( - IN a_guid VARCHAR(36), - IN a_id_user VARCHAR(200), + IN a_guid BINARY(36), + IN a_id_user INT, IN a_get_inactive_users BIT, IN a_ids_permission VARCHAR(500), IN a_ids_access_level VARCHAR(100), @@ -7807,7 +7807,7 @@ BEGIN DECLARE v_priority_access_level_admin INT; DECLARE v_id_access_level INT; DECLARE v_priority_access_level INT; - DECLARE v_now DATETIME; + DECLARE v_now TIMESTAMP; DECLARE v_ids_row_delete VARCHAR(500); DECLARE v_code_error_data VARCHAR(200); DECLARE v_id_error_data INT; @@ -7863,8 +7863,8 @@ BEGIN -- Permanent Table CREATE TABLE IF NOT EXISTS Shop_User_Eval_Temp ( id_row INT PRIMARY KEY AUTO_INCREMENT NOT NULL, - guid VARCHAR(36) NOT NULL, - id_user VARCHAR(200), + guid BINARY(36) NOT NULL, + id_user INT, id_permission_required INT NOT NULL, CONSTRAINT FK_Shop_User_Eval_Temp_id_permission_required FOREIGN KEY (id_permission_required) @@ -7912,13 +7912,13 @@ BEGIN id_access_level_required INT NOT NULL, CONSTRAINT FK_tmp_Shop_Product_p_Shop_User_Eval_id_access_level_required FOREIGN KEY (id_access_level_required) REFERENCES Shop_Access_Level (id_access_level), - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, rank_permutation INT NOT NULL ); CREATE TABLE IF NOT EXISTS tmp_Msg_Error ( display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - guid VARCHAR(36) NOT NULL, + guid BINARY(36) NOT NULL, id_type INT NOT NULL, CONSTRAINT FK_tmp_Msg_Error_id_type FOREIGN KEY (id_type) diff --git a/static/MySQL/temp.txt b/static/MySQL/temp.txt index b257948c..bd58602b 100644 --- a/static/MySQL/temp.txt +++ b/static/MySQL/temp.txt @@ -40,6 +40,7 @@ 1201_tbl_Shop_Category_Audit.sql 1203_tbl_Shop_Product.sql 1204_tbl_Shop_Product_Audit.sql +1205_tbl_Shop_Product_Temp.sql 1206_tbl_Shop_Product_Permutation.sql 1207_tbl_Shop_Product_Permutation_Audit.sql 1208_tbl_Shop_Product_Permutation_Temp.sql @@ -160,6 +161,7 @@ 7219_p_shop_get_many_stock_item.sql 7223_p_shop_get_many_stripe_price_new.sql 7312_p_shop_save_user.sql +7313_p_get_many_user.sql 7321_p_shop_save_user_basket.sql 7400_p_shop_save_supplier.sql 7401_p_shop_get_many_supplier.sql diff --git a/templates/_page_accessibility_statement.html b/templates/_page_accessibility_statement.html index d0cfde74..18ebabf2 100644 --- a/templates/_page_accessibility_statement.html +++ b/templates/_page_accessibility_statement.html @@ -24,9 +24,9 @@ -->

This website is run by {{ model.NAME_COMPANY }}. We want as many people as possible to be able to use this website. For example, that means you should be able to:

    -
  • zoom in up to 400% without the text spilling off the screen
  • -
  • navigate most of the website using just a keyboard or speech recognition software
  • -
  • listen to most of the website using a screen reader (including the most recent versions of NVDA and TalkBack)
  • +
  • Zoom in up to 400% without the text spilling off the screen
  • +
  • Navigate most of the website using just a keyboard or speech recognition software
  • +
  • Listen to most of the website using a screen reader (including the most recent versions of NVDA and TalkBack)
  • We've also made the website text as simple as possible to understand.
  • AbilityNet has advice on making your device easier to use if you have a disability. diff --git a/templates/_page_contact.html b/templates/_page_contact.html index 9f553130..2b181f63 100644 --- a/templates/_page_contact.html +++ b/templates/_page_contact.html @@ -30,42 +30,42 @@ --> - {{ model.form.hidden_tag() }} + {{ model.form_contact.hidden_tag() }}
    - {{ model.form.email.label }} - {{ model.form.email(size=254) }} - {% for error in model.form.email.errors %} + {{ model.form_contact.email.label }} + {{ model.form_contact.email(size=254) }} + {% for error in model.form_contact.email.errors %}

    {{ error }}

    {% endfor %}
    - {{ model.form.name.label }} - {{ model.form.name(size=50) }} - {% for error in model.form.name.errors %} + {{ model.form_contact.name.label }} + {{ model.form_contact.name(size=50) }} + {% for error in model.form_contact.name.errors %}

    {{ error }}

    {% endfor %}
    - {{ model.form.message.label }} - {{ model.form.message(rows=4, cols=80) }} - {% for error in model.form.name.errors %} + {{ model.form_contact.message.label }} + {{ model.form_contact.message(rows=4, cols=80) }} + {% for error in model.form_contact.name.errors %}

    {{ error }}

    {% endfor %}
    - {{ model.form.recaptcha() }} + {{ model.form_contact.recaptcha() }}
    - {{ model.form.submit() }} + {{ model.form_contact.submit() }}
    diff --git a/templates/_page_privacy_notice.html b/templates/_page_privacy_notice.html index 273496a0..d4b912ac 100644 --- a/templates/_page_privacy_notice.html +++ b/templates/_page_privacy_notice.html @@ -26,7 +26,7 @@
  • Legitimate interest:
    • - I collect the user's name and email address alongside a message they send on our 'Contact Us' form in order to respond to their request. Alternatively, the user has the option to contact us directly by email. + We collect the user's name and email address alongside a message they send on our 'Contact Us' form in order to respond to their request. Alternatively, the user has the option to contact us directly by email.
diff --git a/templates/layout.html b/templates/layout.html index 3bac277e..dc892abf 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -6,14 +6,14 @@ {{ model.title }} - {{ model.NAME_COMPANY }} - + @@ -105,6 +108,8 @@ +{% set is_admin_store_user = model.get_is_admin_store_user() %} +{% set is_admin_user_user = model.get_is_admin_user_user() %}
@@ -120,27 +125,29 @@
- Home + Home
- - + {% if is_admin_store_user %} +
+ Admin +
+ {% endif %} {% if model.is_page_store %} + + {% if is_admin_store_user %} + + {% endif %} + {% else %} + {% endif %}
@@ -204,16 +217,8 @@ - - -