CREATE TABLE `tbldelete_tenant_requests` (
  `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
  `status` ENUM('pending','in_progress','completed','failed','skip') NOT NULL DEFAULT 'pending',
  `type` ENUM('cron','manual') DEFAULT 'cron',
  `tenant_id` BIGINT(20) UNSIGNED NOT NULL,
  `user_id` INT(10) UNSIGNED NOT NULL,
  `is_email_sent` TINYINT(1) DEFAULT 0,
  `delete_date` DATE DEFAULT NULL,
  `first_name` VARCHAR(255) DEFAULT NULL,
  `last_name` VARCHAR(255) DEFAULT NULL,
  `company` VARCHAR(255) DEFAULT NULL,
  `email` VARCHAR(100) DEFAULT NULL,
  `phonenumber` VARCHAR(30) DEFAULT NULL,
  `phonenumber_code` VARCHAR(6) DEFAULT '+1',
  `pro_plan_id` BIGINT(20) DEFAULT NULL,
  `deleted_on` DATETIME DEFAULT NULL,
  `added_on` DATETIME NOT NULL,
  `added_by` BIGINT(20) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `tenant_id` (`tenant_id`),
  KEY `user_id` (`user_id`),
  KEY `status` (`status`),
  KEY `type` (`type`)
) ENGINE=INNODB DEFAULT CHARSET=utf8;

INSERT INTO `tblapad_options`
  (`type`, `name`, `value`, `autoload`)
  VALUES ('delete_tenant_cron', 'last_used_days', '90', 1);

INSERT INTO `tblapad_options`
(`type`, `name`, `value`, `autoload`)
VALUES ('delete_tenant_cron', 'delete_tenant_after_days', '7', 1);


INSERT INTO `tblapad_emailtemplates` (`emailtemplateid`, `type`, `slug`, `language`, `name`, `subject`, `message`, `fromname`, `fromemail`, `plaintext`, `active`, `order`, `is_tenant_email_config_allowed`, `is_tenant`) VALUES (NULL, 'delete_tenant', 'delete-tenant-warning', 'english', 'Tenant Delete Warning Mail', 'Action Needed to Keep Your Contractor+ Account Active!', '<p style=\"font-size: 12pt\">Hi {first_name},</p><p style=\"font-size: 12pt\">We hope this message finds you well. We\'ve noticed that you haven\'t logged into your Contractor+ account for the last {last_used_days} days. At Contractor+, we\'re continuously working to improve our platform to ensure our users have the best experience managing their business operations.</p><br/><p style=\"font-size: 12pt;\"><b>Action Required: Log in by {delete_date}</b></p><br/><p style=\"font-size: 12pt;\">To keep your account active and avoid any interruption to your access, please log in to your Contractor+ account by <b>{delete_date}</b>. If your account remains inactive past this date, it will be scheduled for deactivation, and all associated data will be permanently deleted.</p><p style=\"font-size: 12pt;\">Logging in is quick and easy! Plus, it gives you a chance to explore the latest features we\'ve added to help manage your business more efficiently.</p><br/>
<div class=\"o_col_i\" style=\"vertical-align: top;\"><div class=\"o_px-xs\" style=\"padding-left: 8px;padding-right: 8px;\"><table align=\"center\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" role=\"presentation\"><tbody><tr><td class=\"o_btn o_bg-primary o_br o_heading o_text\" align=\"center\" style=\"font-family: Helvetica, Arial, sans-serif;font-weight: bold;margin-top: 0px;margin-bottom: 0px;font-size: 16px;line-height: 24px;mso-padding-alt: 12px 24px;background-color: #C81E1E;border-radius: 4px;\"><a class=\"o_text-white\" href=\"{login_url}\" style=\"color: #ffffff !important;text-decoration: none;outline: none;color: #ffffff;display: block;padding: 12px 24px;mso-text-raise: 3px;\">Log in to Contractor+</a></td></tr></tbody></table></div></div><br /><span style=\"font-size: 12pt\"><b>Why Stay Active?</b></span><br /><span style=\"font-size: 12pt\">By staying active, you ensure continuous access to:<br/>- Your project history and data.<br />- New features and updates designed to streamline your operations.<br />- Our dedicated support team is ready to assist you.</p><p style=\"font-size: 12pt\"><b>Need Assistance?</b><br />If you have any questions or need assistance logging in, our support team is here to help. You can reach us at {support_email_phone}. Thank you for being a part of the Contractor+ community. We look forward to supporting you and your business.<br/><br/><span style=\"font-size: 12pt;\">Best Regards,</span><br/>The Contractor+ Team', '', NULL, '0', '1', '0', '0', '0');

INSERT INTO `tblapad_emailtemplates` (`emailtemplateid`, `type`, `slug`, `language`, `name`, `subject`, `message`, `fromname`, `fromemail`, `plaintext`, `active`, `order`, `is_tenant_email_config_allowed`, `is_tenant`) VALUES (NULL, 'delete_tenant', 'cancel-apple-subscription-warning', 'english', 'Cancel Apple Subscription Warning Mail', 'Important: Action Required Before Account Deletion', '<span style=\"font-size: 12pt\">Dear {first_name},</span><br/><span style=\"font-size: 12pt\">We hope this message finds you well. We\'re reaching out regarding your request to delete your Contractor+ account. Before we can proceed with the deletion, our records indicate that you have an active Apple subscription associated with your account.</span><br/><span style=\"font-size: 12pt;\"><br/><b>For the security and privacy of your financial information, we kindly ask that you cancel your Apple subscription before we can finalize the deletion of your Contractor+ account.</b>This step ensures that you are not billed for any services you no longer wish to use.</span><br/><span style=\"font-size: 12pt\"><br/>Here\'s how you can cancel your Apple subscription:</span><br /><span style=\"font-size: 12pt\">1. Go to your iPhone\'s Settings and tap on your name at the top.<br />2. Tap on \"Subscriptions\"<br />3. Find the subscription for Contractor+ and tap on it.<br />4. Select \"Cancel Subscription\" and follow the prompts to confirm your cancellation.<br/><span style=\"font-size: 12pt;\"><br/>Your satisfaction and data security are our top priorities. If you have any questions or need further assistance, please don\'t hesitate to reach out to our support team at {support_email_phone}. We\'re here to help.</span><br/><br/><span style=\"font-size: 12pt;\">Thank you for your understanding and cooperation.</span><br/><br/><span style=\"font-size: 12pt;\">Best Regards,</span><br/>The Contractor+ Team', '', NULL, '0', '1', '0', '0', '0');

