-- ---------------------------------------------------------------------------
-- pjStripe plugin - schema
-- Run this file first, then config/updates/*.sql in date order.
-- ---------------------------------------------------------------------------

DROP TABLE IF EXISTS `plugin_stripe`;
CREATE TABLE IF NOT EXISTS `plugin_stripe` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `foreign_id` int(10) unsigned DEFAULT NULL,
  `session_id` varchar(255) DEFAULT NULL,
  `txn_id` varchar(255) DEFAULT NULL,
  `amount` decimal(9,2) unsigned DEFAULT NULL,
  `currency` varchar(3) DEFAULT NULL,
  `payer_email` varchar(255) DEFAULT NULL,
  `dt` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `foreign_id` (`foreign_id`),
  UNIQUE KEY `session_id` (`session_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO `fields` (`id`, `key`, `type`, `label`, `source`, `modified`) VALUES
(NULL, 'plugin_stripe_dt', 'backend', 'Stripe plugin / Date & Time', 'plugin', NOW());
SET @id := (SELECT LAST_INSERT_ID());
INSERT INTO `multi_lang` (`id`, `foreign_id`, `model`, `locale`, `field`, `content`, `source`) VALUES
(NULL, @id, 'pjField', '1', 'title', 'Date/Time', 'plugin'),
(NULL, @id, 'pjField', '2', 'title', 'Date/Time', 'plugin'),
(NULL, @id, 'pjField', '3', 'title', 'Date/Time', 'plugin');

INSERT INTO `fields` (`id`, `key`, `type`, `label`, `source`, `modified`) VALUES
(NULL, 'plugin_stripe_amount', 'backend', 'Stripe plugin / Amount', 'plugin', NOW());
SET @id := (SELECT LAST_INSERT_ID());
INSERT INTO `multi_lang` (`id`, `foreign_id`, `model`, `locale`, `field`, `content`, `source`) VALUES
(NULL, @id, 'pjField', '1', 'title', 'Amount', 'plugin'),
(NULL, @id, 'pjField', '2', 'title', 'Amount', 'plugin'),
(NULL, @id, 'pjField', '3', 'title', 'Amount', 'plugin');

INSERT INTO `fields` (`id`, `key`, `type`, `label`, `source`, `modified`) VALUES
(NULL, 'plugin_stripe_currency', 'backend', 'Stripe plugin / Currency', 'plugin', NOW());
SET @id := (SELECT LAST_INSERT_ID());
INSERT INTO `multi_lang` (`id`, `foreign_id`, `model`, `locale`, `field`, `content`, `source`) VALUES
(NULL, @id, 'pjField', '1', 'title', 'Currency', 'plugin'),
(NULL, @id, 'pjField', '2', 'title', 'Currency', 'plugin'),
(NULL, @id, 'pjField', '3', 'title', 'Currency', 'plugin');

INSERT INTO `fields` (`id`, `key`, `type`, `label`, `source`, `modified`) VALUES
(NULL, 'plugin_stripe_payer_email', 'backend', 'Stripe plugin / Payer email', 'plugin', NOW());
SET @id := (SELECT LAST_INSERT_ID());
INSERT INTO `multi_lang` (`id`, `foreign_id`, `model`, `locale`, `field`, `content`, `source`) VALUES
(NULL, @id, 'pjField', '1', 'title', 'Payer email', 'plugin'),
(NULL, @id, 'pjField', '2', 'title', 'Payer email', 'plugin'),
(NULL, @id, 'pjField', '3', 'title', 'Payer email', 'plugin');

INSERT INTO `fields` (`id`, `key`, `type`, `label`, `source`, `modified`) VALUES
(NULL, 'plugin_stripe_txn_id', 'backend', 'Stripe plugin / Txn ID', 'plugin', NOW());
SET @id := (SELECT LAST_INSERT_ID());
INSERT INTO `multi_lang` (`id`, `foreign_id`, `model`, `locale`, `field`, `content`, `source`) VALUES
(NULL, @id, 'pjField', '1', 'title', 'Txn ID', 'plugin'),
(NULL, @id, 'pjField', '2', 'title', 'Txn ID', 'plugin'),
(NULL, @id, 'pjField', '3', 'title', 'Txn ID', 'plugin');

INSERT INTO `fields` (`id`, `key`, `type`, `label`, `source`, `modified`) VALUES
(NULL, 'plugin_stripe_session_id', 'backend', 'Stripe plugin / Session ID', 'plugin', NOW());
SET @id := (SELECT LAST_INSERT_ID());
INSERT INTO `multi_lang` (`id`, `foreign_id`, `model`, `locale`, `field`, `content`, `source`) VALUES
(NULL, @id, 'pjField', '1', 'title', 'Session ID', 'plugin'),
(NULL, @id, 'pjField', '2', 'title', 'Session ID', 'plugin'),
(NULL, @id, 'pjField', '3', 'title', 'Session ID', 'plugin');

INSERT INTO `fields` (`id`, `key`, `type`, `label`, `source`, `modified`) VALUES
(NULL, 'plugin_stripe_foreign_id', 'backend', 'Stripe plugin / Foreign ID', 'plugin', NOW());
SET @id := (SELECT LAST_INSERT_ID());
INSERT INTO `multi_lang` (`id`, `foreign_id`, `model`, `locale`, `field`, `content`, `source`) VALUES
(NULL, @id, 'pjField', '1', 'title', 'Foreign ID', 'plugin'),
(NULL, @id, 'pjField', '2', 'title', 'Foreign ID', 'plugin'),
(NULL, @id, 'pjField', '3', 'title', 'Foreign ID', 'plugin');

INSERT INTO `fields` (`id`, `key`, `type`, `label`, `source`, `modified`) VALUES
(NULL, 'plugin_stripe_btn_view', 'backend', 'Stripe plugin / View', 'plugin', NOW());
SET @id := (SELECT LAST_INSERT_ID());
INSERT INTO `multi_lang` (`id`, `foreign_id`, `model`, `locale`, `field`, `content`, `source`) VALUES
(NULL, @id, 'pjField', '1', 'title', 'View', 'plugin'),
(NULL, @id, 'pjField', '2', 'title', 'View', 'plugin'),
(NULL, @id, 'pjField', '3', 'title', 'View', 'plugin');

INSERT INTO `fields` (`id`, `key`, `type`, `label`, `source`, `modified`) VALUES
(NULL, 'plugin_stripe_btn_close', 'backend', 'Stripe plugin / Close', 'plugin', NOW());
SET @id := (SELECT LAST_INSERT_ID());
INSERT INTO `multi_lang` (`id`, `foreign_id`, `model`, `locale`, `field`, `content`, `source`) VALUES
(NULL, @id, 'pjField', '1', 'title', 'Close', 'plugin'),
(NULL, @id, 'pjField', '2', 'title', 'Close', 'plugin'),
(NULL, @id, 'pjField', '3', 'title', 'Close', 'plugin');

INSERT INTO `fields` (`id`, `key`, `type`, `label`, `source`, `modified`) VALUES
(NULL, 'plugin_stripe_info_title', 'backend', 'Stripe plugin / Transaction details', 'plugin', NOW());
SET @id := (SELECT LAST_INSERT_ID());
INSERT INTO `multi_lang` (`id`, `foreign_id`, `model`, `locale`, `field`, `content`, `source`) VALUES
(NULL, @id, 'pjField', '1', 'title', 'Transaction details', 'plugin'),
(NULL, @id, 'pjField', '2', 'title', 'Transaction details', 'plugin'),
(NULL, @id, 'pjField', '3', 'title', 'Transaction details', 'plugin');

INSERT INTO `fields` (`id`, `key`, `type`, `label`, `source`, `modified`) VALUES
(NULL, 'plugin_stripe_menu_transactions', 'backend', 'Stripe plugin / Transactions', 'plugin', NOW());
SET @id := (SELECT LAST_INSERT_ID());
INSERT INTO `multi_lang` (`id`, `foreign_id`, `model`, `locale`, `field`, `content`, `source`) VALUES
(NULL, @id, 'pjField', '1', 'title', 'Transactions', 'plugin'),
(NULL, @id, 'pjField', '2', 'title', 'Transactions', 'plugin'),
(NULL, @id, 'pjField', '3', 'title', 'Transactions', 'plugin');
