INSERT INTO `{prefix}permission_groups` (`name`, `key`, `created_at`, `updated_at`, `package`, `order`) VALUES
('Marketplace', 'market_place', NOW(), NOW(), 'shaun_market_place', (SELECT MAX(p.`order`) + 1 FROM `{prefix}permission_groups` as p));

INSERT INTO `{prefix}permissions` (`name`, `key`, `is_support_guest`, `group_id`, `created_at`, `updated_at`, `type`, `is_support_moderator`, `order`, `description`) VALUES
('Allow listing creation', 'market_place.allow_listing_creation', 0, (SELECT `id` FROM `{prefix}permission_groups` WHERE `key` = 'market_place'), NOW(), NOW(), 'checkbox', 0, (SELECT MAX(p.`order`) + 1 FROM `{prefix}permissions` as p), "");
INSERT INTO `{prefix}permissions` (`name`, `key`, `is_support_guest`, `group_id`, `created_at`, `updated_at`, `type`, `is_support_moderator`, `order`, `description`) VALUES
('Maximum number of listings can create per day (0 is unlimited)', 'market_place.max_per_day', 0, (SELECT `id` FROM `{prefix}permission_groups` WHERE `key` = 'market_place'), NOW(), NOW(), 'number', 0, (SELECT MAX(p.`order`) + 1 FROM `{prefix}permissions` as p), "");
INSERT INTO `{prefix}permissions` (`name`, `key`, `is_support_guest`, `group_id`, `created_at`, `updated_at`, `type`, `is_support_moderator`, `order`, `description`) VALUES
('Manage Categories', 'market_place.manage_categories', 0, (SELECT `id` FROM `{prefix}permission_groups` WHERE `key` = 'market_place'), NOW(), NOW(), 'checkbox', 1, (SELECT MAX(p.`order`) + 1 FROM `{prefix}permissions` as p), '');
INSERT INTO `{prefix}permissions` (`name`, `key`, `is_support_guest`, `group_id`, `created_at`, `updated_at`, `type`, `is_support_moderator`, `order`, `description`) VALUES
('Manage Listings', 'market_place.manage_listings', 0, (SELECT `id` FROM `{prefix}permission_groups` WHERE `key` = 'market_place'), NOW(), NOW(), 'checkbox', 1, (SELECT MAX(p.`order`) + 1 FROM `{prefix}permissions` as p), '');
INSERT INTO `{prefix}permissions` (`name`, `key`, `is_support_guest`, `group_id`, `created_at`, `updated_at`, `type`, `is_support_moderator`, `order`, `description`) VALUES
('Manage Feature Packages', 'market_place.manage_packages', 0, (SELECT `id` FROM `{prefix}permission_groups` WHERE `key` = 'market_place'), NOW(), NOW(), 'checkbox', 1, (SELECT MAX(p.`order`) + 1 FROM `{prefix}permissions` as p), '');

INSERT INTO `{prefix}translations` (`table_name`, `column_name`, `foreign_key`, `locale`, `value`) VALUES
('permissions', 'message_error', (SELECT `id` FROM `{prefix}permissions` WHERE `key` = 'market_place.allow_listing_creation') ,'en', "You don't have listing creation permission."),
('permissions', 'message_error', (SELECT `id` FROM `{prefix}permissions` WHERE `key` = 'market_place.max_per_day') ,'en', "To prevent spam, we only allow you to share a maximum of [x] listings per day.");

INSERT INTO `{prefix}packages` (`name`, `version`, `created_at`, `updated_at`) VALUES
('shaun_market_place', '1.1.0', NOW(), NOW());

INSERT INTO `{prefix}model_maps` (`subject_type`, `model_class`) VALUES
('market_place_categories', 'Packages\\ShaunSocial\\MarketPlace\\Models\\MarketPlaceCategory'),
('market_place_attributes', 'Packages\\ShaunSocial\\MarketPlace\\Models\\MarketPlaceAttribute'),
('market_place_attribute_values', 'Packages\\ShaunSocial\\MarketPlace\\Models\\MarketPlaceAttributeValue'),
('market_place_listing_reviews', 'Packages\\ShaunSocial\\MarketPlace\\Models\\MarketPlaceListingReview'),
('market_place_listings', 'Packages\\ShaunSocial\\MarketPlace\\Models\\MarketPlaceListing');

INSERT INTO `{prefix}setting_group_subs` (`name`, `group_id`, `key`, `order`, `package`) VALUES
('Marketplace', 2, 'market_place', (SELECT MAX(p.`order`) + 1 FROM `{prefix}setting_group_subs` as p), 'shaun_market_place');

INSERT INTO `{prefix}settings` (`key`, `name`, `description`, `value`, `params`, `type`, `order`, `group_id`, `group_sub_id`, `hidden`) VALUES
('shaun_market_place.enabled', 'Enable', "If this option is disable, member can't access marketplace menu and all existing listings.", '1', '', 'checkbox', 1, 2, (SELECT `id` FROM `{prefix}setting_group_subs` WHERE `key` = 'market_place'), 0),
('shaun_market_place.auto_approve_listing', 'Auto approve new listing', '', '1', '', 'checkbox', 2, 2, (SELECT `id` FROM `{prefix}setting_group_subs` WHERE `key` = 'market_place'), 0),
('shaun_market_place.pending_badge_background_color', 'Pending badge Background Color', '', '#DDCBAD', '{\"path\":\"shaun_market_place::admin.partial.setting.color_input\"}', 'blade', 3, 2, (SELECT `id` FROM `{prefix}setting_group_subs` WHERE `key` = 'market_place'), 0),
('shaun_market_place.pending_badge_border_color', 'Pending badge Border Color', '', '#CBCBCB', '{\"path\":\"shaun_market_place::admin.partial.setting.color_input\"}', 'blade', 4, 2, (SELECT `id` FROM `{prefix}setting_group_subs` WHERE `key` = 'market_place'), 0),
('shaun_market_place.pending_badge_text_color', 'Pending badge Text Color', '', '#000000', '{\"path\":\"shaun_market_place::admin.partial.setting.color_input\"}', 'blade', 5, 2, (SELECT `id` FROM `{prefix}setting_group_subs` WHERE `key` = 'market_place'), 0),
('shaun_market_place.draft_badge_background_color', 'Draft badge Background Color', '', '#4CB3EB', '{\"path\":\"shaun_market_place::admin.partial.setting.color_input\"}', 'blade', 6, 2, (SELECT `id` FROM `{prefix}setting_group_subs` WHERE `key` = 'market_place'), 0),
('shaun_market_place.draft_badge_border_color', 'Draft badge Border Color', '', '#737474 ', '{\"path\":\"shaun_market_place::admin.partial.setting.color_input\"}', 'blade', 7, 2, (SELECT `id` FROM `{prefix}setting_group_subs` WHERE `key` = 'market_place'), 0),
('shaun_market_place.draft_badge_text_color', 'Draft badge Text Color', '', '#000000', '{\"path\":\"shaun_market_place::admin.partial.setting.color_input\"}', 'blade', 8, 2, (SELECT `id` FROM `{prefix}setting_group_subs` WHERE `key` = 'market_place'), 0),
('shaun_market_place.users_can_create_listing', 'Users can create listing', '', '1', '', 'checkbox', 9, 2, (SELECT `id` FROM `{prefix}setting_group_subs` WHERE `key` = 'market_place'), 0),
('shaun_market_place.pages_can_create_listing', 'Pages can create listing', '', '1', '', 'checkbox', 10, 2, (SELECT `id` FROM `{prefix}setting_group_subs` WHERE `key` = 'market_place'), 0),
('shaun_market_place.listing_item_max', 'Maximum photos can be attached', 'Maximum photos that member can attach into a listing', '10', '', 'number', 11, 2, (SELECT `id` FROM `{prefix}setting_group_subs` WHERE `key` = 'market_place'), 0),
('shaun_market_place.description_length_max', 'Maximum description length', 'Maximum number of characters allowed when creating a listing (0 or empty is unlimited).', '1000', '', 'number', 12, 2, (SELECT `id` FROM `{prefix}setting_group_subs` WHERE `key` = 'market_place'), 0),
('shaun_market_place.feature_remind_day', 'Auto-renew listing featured subscription will be notified to users in advance (days)', '', '5', '', 'number', 12, 2, (SELECT `id` FROM `{prefix}setting_group_subs` WHERE `key` = 'market_place'), 0),
('shaun_market_place.auto_create_feed_for_new_listing', 'Auto create feed for new listing', '', '1', '', 'checkbox', 1, 2, (SELECT `id` FROM `{prefix}setting_group_subs` WHERE `key` = 'market_place'), 0);

INSERT INTO `{prefix}layout_maps` (`router`, `layout_class`) VALUES
('market_places', 'Packages\\ShaunSocial\\MarketPlace\\Repositories\\Helpers\\Layout\\MarketPlaceLayout'),
('listings', 'Packages\\ShaunSocial\\MarketPlace\\Repositories\\Helpers\\Layout\\ListingsLayout'),
('listing_detail', 'Packages\\ShaunSocial\\MarketPlace\\Repositories\\Helpers\\Layout\\ListingDetailLayout');

INSERT INTO `{prefix}layout_blocks` (`component`, `title`, `enable`, `class`, `support_header_footer`, `created_at`, `updated_at`, `package`) VALUES
('ListingCategories', 'Categories', 1, 'Packages\\ShaunSocial\\MarketPlace\\Repositories\\Helpers\\Widget\\ListingCategoriesWidget', 0, NOW(), NOW(), 'shaun_market_place'),
('FeaturedListings', 'Featured Listings', 1, 'Packages\\ShaunSocial\\MarketPlace\\Repositories\\Helpers\\Widget\\FeaturedListingsWidget', 0, NOW(), NOW(), 'shaun_market_place'),
('LatestListings', 'Latest Listings', 1, 'Packages\\ShaunSocial\\MarketPlace\\Repositories\\Helpers\\Widget\\LatestListingsWidget', 0, NOW(), NOW(), 'shaun_market_place'),
('NearbyListings', 'Nearby Listings', 1, 'Packages\\ShaunSocial\\MarketPlace\\Repositories\\Helpers\\Widget\\NearbyListingsWidget', 0, NOW(), NOW(), 'shaun_market_place');

INSERT INTO `{prefix}market_place_categories` (`id`,`name`, `order`, `parent_id`, `default_icon`, `is_active`, `enable_condition`, `enable_discount`, `price_type`, `enable_free_delivery`, `created_at`, `updated_at`) VALUES 
(1,'Cars & Vehicles', '1', '0', 'images/default/market_places/cars_and_vehicles.png', '1', '0', '0', NULL, '0', NOW(), NOW()),
(2,'Computers & Accessories', '2', '0', 'images/default/market_places/computer_and_accessories.png', '1', '0', '0', NULL, '0', NOW(), NOW()),
(3,'Devices', '3', '0', 'images/default/market_places/devices.png', '1', '0', '0', NULL, '0', NOW(), NOW()),
(4,'Contracts', '4', '0', 'images/default/market_places/contracts.png', '1', '0', '0', NULL, '0', NOW(), NOW()),
(5,'Electronics & Appliances', '5', '0', 'images/default/market_places/electronics_and_appliances.png', '1', '0', '0', NULL, '0', NOW(), NOW()),
(6,'Fashions', '6', '0', 'images/default/market_places/fashions.png', '1', '0', '0', NULL, '0', NOW(), NOW()),
(7,'Foods', '7', '0', 'images/default/market_places/foods.png', '1', '0', '0', NULL, '0', NOW(), NOW()),
(8,'Furniture', '8', '0', 'images/default/market_places/furnitures.png', '1', '0', '0', NULL, '0', NOW(), NOW()),
(9,'Houses & Lands', '9', '0', 'images/default/market_places/houses_and_lands.png', '1', '0', '0', NULL, '0', NOW(), NOW()),
(10,'Jobs', '10', '0', 'images/default/market_places/jobs.png', '1', '0', '0', NULL, '0', NOW(), NOW()),
(11,'Pet Services', '11', '0', 'images/default/market_places/pet_services.png', '1', '0', '0', NULL, '0', NOW(), NOW()),
(12,'Phone & Tablets', '12', '0', 'images/default/market_places/phone_and_tablets.png', '1', '0', '0', NULL, '0', NOW(), NOW());

INSERT INTO `{prefix}translations` (`table_name`, `column_name`, `foreign_key`, `locale`, `value`) VALUES
('market_place_categories', 'name', 1, 'en', 'Cars & Vehicles'),
('market_place_categories', 'name', 2, 'en', 'Computers & Accessories'),
('market_place_categories', 'name', 3, 'en', 'Devices'),
('market_place_categories', 'name', 4, 'en', 'Contracts'),
('market_place_categories', 'name', 5, 'en', 'Electronics & Appliances'),
('market_place_categories', 'name', 6, 'en', 'Fashions'),
('market_place_categories', 'name', 7, 'en', 'Foods'),
('market_place_categories', 'name', 8, 'en', 'Furniture'),
('market_place_categories', 'name', 9, 'en', 'Houses & Lands'),
('market_place_categories', 'name', 10, 'en', 'Jobs'),
('market_place_categories', 'name', 11, 'en', 'Pet Services'),
('market_place_categories', 'name', 12, 'en', 'Phone & Tablets');

INSERT INTO `{prefix}subscription_types` (`type`, `order`, `class`, `show`) VALUES
('listing_feature', 1, 'Packages\\ShaunSocial\\MarketPlace\\Subscription\\SubscriptionTypeListingFeature', 'page');

INSERT INTO `{prefix}wallet_transaction_sub_types` (`parent_type_id`, `type`, `class`) VALUES
(4, 'listing_feature_buy', 'Packages\\ShaunSocial\\MarketPlace\\Wallet\\Payment\\MarketPlaceTransactionTypeBuyFeature');

INSERT INTO `{prefix}wallet_transaction_sub_types` (`parent_type_id`, `type`, `class`) VALUES
((SELECT `id` FROM `{prefix}wallet_transaction_types` WHERE `type` = 'commission'), 'listing_feature_buy', 'Packages\\ShaunSocial\\MarketPlace\\Wallet\\Commission\\MarketPlaceTransactionTypeListingFeature');
