-- 21st Sept 2021
ALTER TABLE `tblsms_templates` CHANGE `type` `type` ENUM('estimate','invoice','post_inspection','business_review','client_referral','estimate_expiration_reminder','invoice_overdue_reminder');
ALTER TABLE `tblsms_templates_static` CHANGE `type` `type` ENUM('estimate','invoice','post_inspection','business_review','client_referral','estimate_expiration_reminder','invoice_overdue_reminder');
INSERT INTO tblsms_templates_static values (NULL, 'estimate_expiration_reminder', 'Hi {contact_firstname}, Estimate #{estimate_number} will expire on {estimate_expirydate}');
INSERT INTO tblsms_templates  SELECT NULL, id,'estimate_expiration_reminder', 'Hi {contact_firstname}, Estimate #{estimate_number} will expire on {estimate_expirydate}', NOW(), NOW() FROM tbltenants;

INSERT INTO `tblmobile_push_notification_config` (`id`, `codename`, `is_active`) VALUES (NULL, 'estimate_expired', '1');

-- 22nd Sept 2021
UPDATE tblinvoices SET status = 6 WHERE status = 1 AND sent != 1 AND datesend IS NULL;
ALTER TABLE `tblinvoices` CHANGE `status` `status` BIGINT(20) UNSIGNED NULL DEFAULT '6';

INSERT INTO tblsms_templates_static values (NULL, 'invoice_overdue_reminder', 'Hi {contact_firstname}, Invoice #{invoice_number} was Overdue on {invoice_duedate}');
INSERT INTO tblsms_templates  SELECT NULL, id,'invoice_overdue_reminder', 'Hi {contact_firstname}, Invoice #{invoice_number} was Overdue on {invoice_duedate}', NOW(), NOW() FROM tbltenants;
INSERT INTO `tblmobile_push_notification_config` (`id`, `codename`, `is_active`) VALUES (NULL, 'invoice_overdue', '1');

UPDATE tblinvoices SET cancel_overdue_reminders = 0;