START TRANSACTION;

  DROP TABLE IF EXISTS `clients`;
  CREATE TABLE IF NOT EXISTS `clients` (
    `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
    `username` VARCHAR(255) NOT NULL,
    `password` BLOB NOT NULL,
    `email` VARCHAR(255) NOT NULL,
    `active` ENUM('T','F') NOT NULL DEFAULT 'F',
    PRIMARY KEY (`id`)
  ) ENGINE = InnoDB;

  DROP TABLE IF EXISTS `clients_urls`;
  CREATE TABLE IF NOT EXISTS `clients_urls` (
    `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
    `client_id` INT UNSIGNED NOT NULL,
    `code` TEXT NOT NULL,
    `attempts` INT UNSIGNED NOT NULL DEFAULT 0,
    `expired` ENUM('T','F') NOT NULL DEFAULT 'F',
    `active` ENUM('T','F') NOT NULL DEFAULT 'F',
    `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`)
  ) ENGINE = InnoDB;

  
  INSERT INTO `plugin_base_fields` VALUES (NULL, 'lblUsername', 'backend', 'Label / Username', 'script', '2017-03-09 05:27:35');
  SET @id := (SELECT LAST_INSERT_ID());
  INSERT INTO `plugin_base_multi_lang` VALUES (NULL, @id, 'pjBaseField', '::LOCALE::', 'title', 'Username', 'script');

  INSERT INTO `plugin_base_fields` VALUES (NULL, 'lblPassword', 'backend', 'Label / Password', 'script', '2017-03-09 05:27:35');
  SET @id := (SELECT LAST_INSERT_ID());
  INSERT INTO `plugin_base_multi_lang` VALUES (NULL, @id, 'pjBaseField', '::LOCALE::', 'title', 'Password', 'script');

  INSERT INTO `plugin_base_fields` VALUES (NULL, 'lblEmail', 'backend', 'Label / Email', 'script', '2017-03-09 05:27:35');
  SET @id := (SELECT LAST_INSERT_ID());
  INSERT INTO `plugin_base_multi_lang` VALUES (NULL, @id, 'pjBaseField', '::LOCALE::', 'title', 'Email', 'script');

  INSERT INTO `plugin_base_fields` VALUES (NULL, 'error_titles_ARRAY_AC03', 'arrays', 'error_titles_ARRAY_AC03', 'script', '2017-03-09 05:27:35');
  SET @id := (SELECT LAST_INSERT_ID());
  INSERT INTO `plugin_base_multi_lang` VALUES (NULL, @id, 'pjBaseField', '::LOCALE::', 'title', 'Client added!', 'script');

  INSERT INTO `plugin_base_fields` VALUES (NULL, 'error_bodies_ARRAY_AC03', 'arrays', 'error_bodies_ARRAY_AC03', 'script', '2017-03-09 05:27:35');
  SET @id := (SELECT LAST_INSERT_ID());
  INSERT INTO `plugin_base_multi_lang` VALUES (NULL, @id, 'pjBaseField', '::LOCALE::', 'title', 'All the changes made to this client have been saved.', 'script');

  INSERT INTO `plugin_base_fields` VALUES (NULL, 'error_titles_ARRAY_AC01', 'arrays', 'error_titles_ARRAY_AC01', 'script', '2017-03-09 05:27:35');
  SET @id := (SELECT LAST_INSERT_ID());
  INSERT INTO `plugin_base_multi_lang` VALUES (NULL, @id, 'pjBaseField', '::LOCALE::', 'title', 'Client updated!', 'script');

  INSERT INTO `plugin_base_fields` VALUES (NULL, 'error_bodies_ARRAY_AC01', 'arrays', 'error_bodies_ARRAY_AC01', 'script', '2017-03-09 05:27:35');
  SET @id := (SELECT LAST_INSERT_ID());
  INSERT INTO `plugin_base_multi_lang` VALUES (NULL, @id, 'pjBaseField', '::LOCALE::', 'title', 'All the changes made to this client have been saved.', 'script');

  INSERT INTO `plugin_base_fields` VALUES (NULL, 'notify_arr_ARRAY_registration', 'arrays', 'notify_arr_ARRAY_registration', 'script', '2017-03-09 05:27:35');
  SET @id := (SELECT LAST_INSERT_ID());
  INSERT INTO `plugin_base_multi_lang` VALUES (NULL, @id, 'pjBaseField', '::LOCALE::', 'title', 'Client - registration link email', 'script');

  INSERT INTO `plugin_base_fields` VALUES (NULL, 'notify_arr_ARRAY_recovery', 'arrays', 'notify_arr_ARRAY_recovery', 'script', '2017-03-09 05:27:35');
  SET @id := (SELECT LAST_INSERT_ID());
  INSERT INTO `plugin_base_multi_lang` VALUES (NULL, @id, 'pjBaseField', '::LOCALE::', 'title', 'Client - registration recovery email', 'script');

  INSERT INTO `plugin_base_multi_lang` VALUES (NULL, 1, 'pjCalendar', '::LOCALE::', 'client_subject_registration', '', 'data');
  INSERT INTO `plugin_base_multi_lang` VALUES (NULL, 1, 'pjCalendar', '::LOCALE::', 'client_tokens_registration', '<p>&nbsp;</p>\r\n<p>Hi, {Username}.<br /><br /></p>\r\n<p>You are now registered in our booking system.<br />This is the link to log in to the calendar:&nbsp;{Link}</p>\r\n<p>Remember, these data will expire soon.</p>\r\n<p>Recuerda&nbsp;que estos datos se quedan activos por un tiempo limitado:<br /><br /></p>\r\n<p>Username: {Username}&nbsp;<br />Password: {Password}<br /><br /></p>\r\n<p>Important: These data are personal and no transferables.<br /><br />If you have any questions, please, contact us:&nbsp;<a href=\"mailto:info@calogerogrifasi.com\">info@calogerogrifasi.com</a></p>\r\n<p>&nbsp;</p>\r\n<p>Thank you,<br />Team Grifasi</p>', 'data');
  

  INSERT INTO `plugin_base_multi_lang` VALUES (NULL, 1, 'pjCalendar', '::LOCALE::', 'client_subject_recovery', '', 'data');
  INSERT INTO `plugin_base_multi_lang` VALUES (NULL, 1, 'pjCalendar', '::LOCALE::', 'client_tokens_recovery', '<p>&nbsp;</p>\r\n<p>Hi, {Name}.</p>\r\n<p>&nbsp;</p>\r\n<p>Here we sent you your personal data:<br /><br /></p>\r\n<p>Usuario:&nbsp;<strong>{Username}</strong><br />Contrase&ntilde;a:&nbsp;<strong>{Password}<br /><br /></strong></p>\r\n<p>Important: These data are personal and no transferables.<br /><br />If you have any questions, please, contact us:&nbsp;<a href=\"mailto:info@calogerogrifasi.com\">info@calogerogrifasi.com</a></p>\r\n<p>&nbsp;</p>\r\n<p>Thanks,<br />Team Grifasi</p>\r\n<p>&nbsp;</p>', 'data');

  INSERT INTO `plugin_base_fields` VALUES (NULL, 'lblLogin', 'frontend', 'Label / Login', 'script', '2017-03-09 05:27:35');
  SET @id := (SELECT LAST_INSERT_ID());
  INSERT INTO `plugin_base_multi_lang` VALUES (NULL, @id, 'pjBaseField', '::LOCALE::', 'title', 'Login', 'script');

  INSERT INTO `plugin_base_fields` VALUES (NULL, 'lblForgotPassword', 'frontend', 'Label / Forgot password', 'script', '2017-03-09 05:27:35');
  SET @id := (SELECT LAST_INSERT_ID());
  INSERT INTO `plugin_base_multi_lang` VALUES (NULL, @id, 'pjBaseField', '::LOCALE::', 'title', 'Forgot password?', 'script');

  INSERT INTO `plugin_base_fields` VALUES (NULL, 'lblInvalidLogin', 'frontend', 'Label / Invalid login', 'script', '2017-03-09 05:27:35');
  SET @id := (SELECT LAST_INSERT_ID());
  INSERT INTO `plugin_base_multi_lang` VALUES (NULL, @id, 'pjBaseField', '::LOCALE::', 'title', 'Invalid username or password', 'script');

  INSERT INTO `options` (`foreign_id`, `key`, `tab_id`, `value`, `label`, `type`, `order`, `is_visible`, `style`) VALUES
    (1, 'o_login_attempts', 3, 3, NULL, 'int', 14, 1, NULL),
    (1, 'o_link_expiration_hours', 3, 48, NULL, 'int', 15, 1, NULL);

  INSERT INTO `plugin_base_fields` VALUES (NULL, 'opt_o_login_attempts', 'backend', 'Options / Login attempts', 'script', '2015-11-17 07:11:13');
  SET @id := (SELECT LAST_INSERT_ID());
  INSERT INTO `plugin_base_multi_lang` VALUES (NULL, @id, 'pjBaseField', '::LOCALE::', 'title', 'Login attempts', 'script');

  INSERT INTO `plugin_base_fields` VALUES (NULL, 'opt_o_link_expiration_hours', 'backend', 'Options / Link expiration hours', 'script', '2015-11-17 07:11:13');
  SET @id := (SELECT LAST_INSERT_ID());
  INSERT INTO `plugin_base_multi_lang` VALUES (NULL, @id, 'pjBaseField', '::LOCALE::', 'title', 'The link will expire in', 'script');

  INSERT INTO `plugin_base_fields` VALUES (NULL, 'lblBackToLogin', 'frontend', 'Label / Back to login', 'script', '2015-11-17 07:11:13');
  SET @id := (SELECT LAST_INSERT_ID());
  INSERT INTO `plugin_base_multi_lang` VALUES (NULL, @id, 'pjBaseField', '::LOCALE::', 'title', 'Back to login', 'script');

  INSERT INTO `plugin_base_fields` VALUES (NULL, 'lblForgotPasswordSuccess', 'frontend', 'Label / Forgot password success', 'script', '2015-11-17 07:11:13');
  SET @id := (SELECT LAST_INSERT_ID());
  INSERT INTO `plugin_base_multi_lang` VALUES (NULL, @id, 'pjBaseField', '::LOCALE::', 'title', 'Email has been send successful.', 'script');

  INSERT INTO `plugin_base_fields` VALUES (NULL, 'error_titles_ARRAY_AC05', 'arrays', 'error_titles_ARRAY_AC05', 'script', '2017-03-09 05:27:35');
  SET @id := (SELECT LAST_INSERT_ID());
  INSERT INTO `plugin_base_multi_lang` VALUES (NULL, @id, 'pjBaseField', '::LOCALE::', 'title', 'Email sent', 'script');

  INSERT INTO `plugin_base_fields` VALUES (NULL, 'error_bodies_ARRAY_AC05', 'arrays', 'error_bodies_ARRAY_AC05', 'script', '2017-03-09 05:27:35');
  SET @id := (SELECT LAST_INSERT_ID());
  INSERT INTO `plugin_base_multi_lang` VALUES (NULL, @id, 'pjBaseField', '::LOCALE::', 'title', 'Email has been sent successful.', 'script');

  INSERT INTO `plugin_base_fields` VALUES (NULL, 'btnPaymentConfirmationEmail', 'frontend', 'Button / Send payment email', 'script', '2017-03-09 05:27:35');
  SET @id := (SELECT LAST_INSERT_ID());
  INSERT INTO `plugin_base_multi_lang` VALUES (NULL, @id, 'pjBaseField', '::LOCALE::', 'title', 'Send Payment Email', 'script');

  INSERT INTO `options` (`foreign_id`, `key`, `tab_id`, `value`, `label`, `type`, `order`, `is_visible`, `style`) VALUES
    (1, 'o_cancel_pending_reservations', 3, 48, NULL, 'int', 16, 1, NULL);

  

COMMIT;