Add A 2nd Domain

FYI: The following instructions set up a new domain. However, testing of all SI features for the new domain have not been fully tested. Please test the features you require before putting them into production.

Replace “@domain_username” with a username that is unique in the si_user table.
Replace “@domain_pwd” with the password you want to assign to the new user.
Replace “@domain_email” with the email address for the new user.
Replace “@domain_name” with the name of this user.
Replace “@domain_num” with the new domain number (ex: 2)

INSERT INTO `si_user_domain` (`id`, `name`) VALUES (@domain_num, '@domain_name');

INSERT INTO `si_user` (`email`, `role_id`, `domain_id`, `password`, `enabled`, `user_id`, `username`)
VALUES ('@domain_email', 1, @domain_num, SHA2('@domain_pwd', 256), 1, 0, '@domain_username');

INSERT INTO `si_tax` (`tax_description`, `tax_percentage`, `type`, `tax_enabled`, `domain_id`)
VALUES ('No Tax',     0.000000, '%', '1', @domain_num),
       ('GST',        7.000000, '%', '1', @domain_num),
       ('VAT',       10.000000, '%', '1', @domain_num),
       ('Sales Tax', 10.000000, '%', '1', @domain_num),
       ('Postage',   20.000000, '$', '1', @domain_num);

INSERT INTO `si_custom_flags` (`domain_id`, `associated_table`, `flg_id`, `field_label`, `enabled`, `field_help`)
VALUES (@domain_num, 'products',  1, '', 0, ''),
       (@domain_num, 'products',  2, '', 0, ''),
       (@domain_num, 'products',  3, '', 0, ''),
       (@domain_num, 'products',  4, '', 0, ''),
       (@domain_num, 'products',  5, '', 0, ''),
       (@domain_num, 'products',  6, '', 0, ''),
       (@domain_num, 'products',  7, '', 0, ''),
       (@domain_num, 'products',  8, '', 0, ''),
       (@domain_num, 'products',  9, '', 0, ''),
       (@domain_num, 'products', 10, '', 0, '');

INSERT INTO `si_custom_fields` (`cf_custom_field`, `cf_custom_label`, `cf_display`, `domain_id`)
VALUES ('biller_cf1',   NULL, '0', @domain_num),
       ('biller_cf2',   NULL, '0', @domain_num),
       ('biller_cf3',   NULL, '0', @domain_num),
       ('biller_cf4',   NULL, '0', @domain_num),
       ('customer_cf1', NULL, '0', @domain_num),
       ('customer_cf2', NULL, '0', @domain_num),
       ('customer_cf3', NULL, '0', @domain_num),
       ('customer_cf4', NULL, '0', @domain_num),
       ('product_cf1',  NULL, '0', @domain_num),
       ('product_cf2',  NULL, '0', @domain_num),
       ('product_cf3',  NULL, '0', @domain_num),
       ('product_cf4',  NULL, '0', @domain_num),
       ('invoice_cf1',  NULL, '0', @domain_num),
       ('invoice_cf2',  NULL, '0', @domain_num),
       ('invoice_cf3',  NULL, '0', @domain_num),
       ('invoice_cf4',  NULL, '0', @domain_num);

INSERT INTO `si_payment_types` (`domain_id`, `pt_description`, `pt_enabled`)
VALUES (@domain_num, 'Cash',        '1'),
       (@domain_num, 'Credit Card', '1');

INSERT INTO `si_preferences` (`domain_id`, `pref_description`, `pref_currency_sign`,
                              `pref_inv_heading`, `pref_inv_wording`, `pref_inv_detail_heading`,
                              `pref_inv_detail_line`, `pref_inv_payment_method`,
                              `pref_inv_payment_line1_name`, `pref_inv_payment_line1_value`,
                              `pref_inv_payment_line2_name`, `pref_inv_payment_line2_value`,
                              `pref_enabled`, `status`, `locale`, `language`, `index_group`,
                              `currency_code`, `include_online_payment`, `currency_position`)
VALUES (@domain_num, 'AltInvoice', '$', 'Invoice', 'Invoice', 'Details',
        'Payment is to be made within 14 days of the invoice being sent', 'Electronic Funds Transfer',
        'Account name', 'H. & M. Simpson', 'Account number:', '0123-4567-7890',
        1, 1, 'en_US', 'en_US', 1, 'USD', NULL, 'left'),
       (@domain_num, 'AltReceipt', '$', 'Receipt', 'Receipt', 'Details',
        'This transaction has been paid in full, please keep this receipt as proof of purchase.<br/> Thank you',
        '', '', '', '', '', 1, 1, 'en_US', 'en_US', 1, 'USD', NULL, 'left'),
       (@domain_num, 'AltEstimate', '$', 'Estimate', 'Estimate', 'Details',
        'This is an estimate of the final value of services rendered.<br/>Thank you',
        '', '', '', '', '', '1', 1, 'en_US', 'en_US', 1, 'USD', NULL, 'left'),
       (@domain_num, 'AltQuote', '$', 'Quote', 'Quote', 'Details',
        'This is a quote of the final value of services rendered.<br/>Thank you',
        '', '', '', '', '', '1', 1, 'en_US', 'en_US', 1, 'USD', NULL, 'left');

INSERT INTO `si_system_defaults`
  SELECT * FROM (
    SELECT NULL AS id, a.name, a.value, @domain_num AS domain_id, extension_id
    FROM `si_system_defaults` a
    WHERE a.domain_id = 1
      AND a.name NOT IN (SELECT b.name FROM `si_system_defaults` b WHERE b.domain_id = @domain_num)) c;