
USE partsltd_prod;


-- Error Message Types
INSERT INTO partsltd_prod.CORE_Msg_Error_Type (
	  code
    , name
    , description
)
VALUES 
	(
          'BAD_DATA'
        , 'Invalid data'
        , 'Rubbish data'
    )
	, (
          'NO_PERMISSION'
        , 'No permission'
        , 'Not authorised'
    )
    , (
          'MYSQL_ERROR'
        , 'MySQL error'
        , 'MySQL execution error.'
    )
    , (
          'WARNING'
        , 'Warning'
        , 'Non-breaking error.'
    )
;

-- Access Levels
INSERT INTO partsltd_prod.PH_Access_Level (
	  display_order
    , code
    , name
    , priority
)
VALUES 
	(
          1
        , 'VIEW'
        , 'View'
        , 3
    )
	, (
          2
        , 'EDIT'
        , 'Edit'
        , 2
    )
	, (
          3
        , 'ADMIN'
        , 'Admin'
        , 1
    )
;

-- Permission Groups
INSERT INTO partsltd_prod.PH_Permission_Group (
	display_order
    , code
    , name
)
VALUES 
	(
          0
        , 'CONTACT_FORM'
        , 'Contact Form'
    )
	, (
          1
        , 'USER'
        , 'Admin User'
    )
;

-- Permissions
INSERT INTO partsltd_prod.PH_Permission (
	  display_order
    , code
    , name
    , id_permission_group
    , id_access_level_required
)
VALUES 
	(
          1
        , 'CONTACT_FORM_NEW'
        , 'New Contact Form'
        , 1
        , 3
    )
	, (
          1
        , 'CONTACT_FORM_ADMIN'
        , 'Admin Contact Form'
        , 1
        , 3
    )
	, (
          1
        , 'CONTACT_FORM_CREATE'
        , 'Create Contact Form'
        , 1
        , 1
    )
;

-- Users
INSERT INTO partsltd_prod.PH_User (
	  id_user_auth0
	, firstname
    , surname
	, email
	, is_super_user
    , active
)
VALUES 
	(
		  'auth0|6582b95c895d09a70ba10fef' -- id_user_auth0
		, 'Teddy' -- firstname
        , 'Middleton-Smith' -- surname
        , 'edward.middletonsmith@gmail.com' -- email
        , 1 -- is_super_user
		, 1 -- active
	)
    , (
		'auth0|672659014296b7f94a9bab45' -- id_user_auth0
		, 'Tierney' -- firstname
		, 'Gullen' -- surname
		, 'tierneybailey13@gmail.com' -- email
		, 1 -- is_super_user
		, 1 -- active
	)
    , (
          NULL -- id_user_auth0
        , 'Contact Form Bot' -- firstname
        , 'Bot' -- surname
        , 'teddy@partsltd.co.uk' -- email
        , 0 -- is_super_user
        , 1 -- active
    )
;

-- Roles
INSERT INTO partsltd_prod.PH_Role (
	  display_order
	, code
	, name
    , id_user_created_by
)
VALUES 
	  (
          1
        , 'DIRECTOR'
        , 'Director'
        , 1
    )
	, (
          2
        , 'USER'
        , 'User'
        , 1
    )
;

-- Role Permission link
INSERT INTO partsltd_prod.PH_Role_Permission_Link (
	  id_role
    , id_permission
    , id_access_level
    , id_user_created_by
)
VALUES 
	  (
          1
        , 1
        , 3
        , 1
    )
	, (
          1
        , 2
        , 3
        , 1
    )
	, (
          1
        , 3
        , 3
        , 1
    )
	, (
          2
        , 1
        , 1
        , 1
    )
	, (
          2
        , 2
        , 1
        , 1
    )
	, (
          2
        , 3
        , 1
        , 1
    )
;

-- User Role link
INSERT INTO partsltd_prod.PH_User_Role_Link (
	  id_user
    , id_role
    , id_user_created_by
)
VALUES 
	(
          1
        , 1
        , 1
    )
	, (
          2
        , 2
        , 1
    )
	, (
          3
        , 2
        , 1
    )
;


INSERT INTO partsltd_prod.PH_Contact_Form (
      email
    , name_contact
    , name_company
    , message
    , id_user_created_by
)
VALUES 
      (
          'edward.middleton-smith@gmail.com'
        , 'Teddy Middleton-Smith'
        , 'PARTS Ltd'
        , 'Hello, I would like to enquire about your services.'
        , 1
    )
;