-- ACTIVITY AND ACTION INSERT QUERY

INSERT INTO `tblin_app_activity_events` (`module_name`, `event_key`, `message`, `icon`, `priority`, `is_actionable`, `web_redirection`, `mobile_redirection`, `added_by`, `added_on`, `updated_by`, `updated_on`) VALUES ('custom', 'share_your_feedback_on_the_lowes_integration_for_a_chance_to_win_one_of_3_lowes_gift_cards', 'Share your feedback on the Lowe\'s Integration for a chance to win one of 3 Lowe\'s gift cards', 'general-activity.svg', 0, 1, 'https://forms.gle/mbVpqsf3cQnbkqfA6', '{"type":"external_webview","external_webview":{"external_webview_url":"https:\\/\\/forms.gle\\/mbVpqsf3cQnbkqfA6"}}', NULL, UTC_TIMESTAMP(), NULL, UTC_TIMESTAMP());

SET @activity_id = LAST_INSERT_ID();

INSERT INTO `tblin_app_activity_actions` (`activity_event_id`, `action_name`, `action_label`, `icon`, `permission`, `web_redirection`, `mobile_redirection`, `added_on`, `updated_on`) VALUES (@activity_id, 'share_feedback', 'Share Feedback', 'general-activity.svg', '', 'https://forms.gle/mbVpqsf3cQnbkqfA6', '{"type":"external_webview","external_webview":{"external_webview_url":"https:\\/\\/forms.gle\\/mbVpqsf3cQnbkqfA6"}}', UTC_TIMESTAMP(), UTC_TIMESTAMP());


-- IAN INSERT QUERY

-- Tenant Query for all Tenant
INSERT INTO tblin_app_logs(`tenant_id`, `staff_id`, `for`, `client_id`, `rel_type`, `rel_id`, `action`, `priority`, `description`, `marked_as_read`, `is_actionable_item`, `actionable_item_title`, `marked_as_done`, `is_item_deleted`, `additional_data`, `action_performed_by`, `action_performed_by_id`, `display_on`, `added_on`, `modified_on`)
Select st.tenant_id, st.staffid, 'tenant', NULL, 'custom', NULL, 'share_your_feedback_on_the_lowes_integration_for_a_chance_to_win_one_of_3_lowes_gift_cards', 0, 'Share your feedback on the Lowe\'s Integration for a chance to win one of 3 Lowe\'s gift cards', 0, 1, '', 0, 0, NULL, 'staff', st.staffid, UTC_TIMESTAMP(), UTC_TIMESTAMP(), UTC_TIMESTAMP()
FROM  tbltenants t  
JOIN tblstaff st ON st.tenant_id = t.id and st.is_tenant = 1;



-- Staff Query for All Staff 

INSERT INTO tblin_app_logs(`tenant_id`, `staff_id`, `for`, `client_id`, `rel_type`, `rel_id`, `action`, `priority`, `description`, `marked_as_read`, `is_actionable_item`, `actionable_item_title`, `marked_as_done`, `is_item_deleted`, `additional_data`, `action_performed_by`, `action_performed_by_id`, `display_on`, `added_on`, `modified_on`)
Select st.tenant_id, st.staffid, 'staff', NULL, 'custom', NULL, 'share_your_feedback_on_the_lowes_integration_for_a_chance_to_win_one_of_3_lowes_gift_cards', 0, 'Share your feedback on the Lowe\'s Integration for a chance to win one of 3 Lowe\'s gift cards', 0, 1, '', 0, 0, NULL, 'staff', st.staffid, UTC_TIMESTAMP(), UTC_TIMESTAMP(), UTC_TIMESTAMP()
FROM  tbltenants t  
JOIN tblstaff st ON st.tenant_id = t.id and st.is_tenant != 1;

-- Staff Query for Active Staff only

INSERT INTO tblin_app_logs(`tenant_id`, `staff_id`, `for`, `client_id`, `rel_type`, `rel_id`, `action`, `priority`, `description`, `marked_as_read`, `is_actionable_item`, `actionable_item_title`, `marked_as_done`, `is_item_deleted`, `additional_data`, `action_performed_by`, `action_performed_by_id`, `display_on`, `added_on`, `modified_on`)
Select st.tenant_id, st.staffid, 'staff', NULL, 'custom', NULL, 'share_your_feedback_on_the_lowes_integration_for_a_chance_to_win_one_of_3_lowes_gift_cards', 0, 'Share your feedback on the Lowe\'s Integration for a chance to win one of 3 Lowe\'s gift cards', 0, 1, '', 0, 0, NULL, 'staff', st.staffid, UTC_TIMESTAMP(), UTC_TIMESTAMP(), UTC_TIMESTAMP()
FROM  tbltenants t  
JOIN tblstaff st ON st.tenant_id = t.id and st.is_tenant != 1 AND st.`active` = 1;