-- SMS module + permissions (run once on existing databases)

INSERT INTO permissions (module, action, slug) VALUES
('sms', 'view', 'sms.view'),
('sms', 'send', 'sms.send')
ON DUPLICATE KEY UPDATE slug = VALUES(slug);

INSERT IGNORE INTO role_permissions (role_id, permission_id)
SELECT 1, id FROM permissions WHERE module = 'sms';

INSERT IGNORE INTO role_permissions (role_id, permission_id)
SELECT 2, id FROM permissions WHERE module = 'sms';

INSERT IGNORE INTO role_permissions (role_id, permission_id)
SELECT 3, id FROM permissions WHERE module = 'sms';

INSERT IGNORE INTO role_permissions (role_id, permission_id)
SELECT 4, id FROM permissions WHERE module = 'sms';

UPDATE settings SET `value` = '1' WHERE `key` = 'mod_sms' AND (`value` = '0' OR `value` = '');

INSERT INTO settings (`key`, `value`) VALUES
('mod_customer_groups', '1'),
('mod_rewards', '1'),
('mod_sms', '1'),
('sms_api_url', 'http://bulksmsbd.net/api/smsapi'),
('sms_api_key', ''),
('sms_sender_id', ''),
('sms_append_business', '1'),
('sms_on_sale_customer', '0'),
('sms_on_purchase_supplier', '0')
ON DUPLICATE KEY UPDATE `key` = VALUES(`key`);
