CREATE TABLE IF NOT EXISTS tblquickbid_items_description (
  id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
  tenant_id BIGINT(20) UNSIGNED NOT NULL,
  estimate_id BIGINT(20) UNSIGNED NOT NULL,  
  type enum('labour','supply') NOT NULL, 
  description VARCHAR(500),
  added_on DATETIME NOT NULL,
  PRIMARY KEY (id)
) ENGINE=INNODB DEFAULT CHARSET=utf8 ;

ALTER TABLE tblestimates MODIFY COLUMN type enum('detail','normal','quickbid_estimate') NOT NULL DEFAULT 'normal';

ALTER TABLE tblmodule_taxes MODIFY COLUMN rel_type enum('estimate', 'invoice', 'detail_estimate','quickbid_estimate') NOT NULL;

INSERT INTO tblemailtemplates_static (type,slug,language,name,subject,message,fromname,fromemail,plaintext,active,`order`)
VALUES('estimate','quickbid-estimate-send-to-client','english','Send Quickbid Estimate to Customer','New Estimate for {estimate_client_property_street_1} {estimate_client_property_street_2}','<span style="font-size: 12pt;">Hi {contact_firstname} {contact_lastname},</span><br/><br/><span style="font-size: 12pt;">Attached is a new estimate for {estimate_client_address_street}. The labour total comes to {labour_total_charge}. The supply total comes to {supply_total_charge}. The taxes come to: {total_tax}. The grand total of your estimate is {estimate_total}.</span><br/><br/><span style="font-size: 12pt;">You can view the detailed estimate at this link: <a href="{estimate_link}">{estimate_number}-{estimate_client_property_street_1}{estimate_client_property_street_2}.pdf.</a></span><br/><br/><span style="font-size: 12pt;">If you have any questions, I\'m here to help!</span><br/><br/><span style="font-size: 12pt;">{email_signature}</span>','{companyname}','',0,1,0);


INSERT INTO tblemailtemplates_static (type,slug,language,name,subject,message,fromname,fromemail,plaintext,active,`order`)
VALUES('estimate','quickbid-estimate-already-send','english','Quickbid Estimate Already Sent to Customer','New Estimate for {estimate_client_property_street_1} {estimate_client_property_street_2}','<span style="font-size: 12pt;">Hi {contact_firstname} {contact_lastname},</span><br/><br/><span style="font-size: 12pt;">Attached is a new estimate for {estimate_client_address_street}. The labour total comes to {labour_total_charge}. The supply total comes to {supply_total_charge}. The taxes come to: {total_tax}. The grand total of your estimate is {estimate_total}.</span><br/><br/><span style="font-size: 12pt;">You can view the detailed estimate at this link: <a href="{estimate_link}">{estimate_number}-{estimate_client_property_street_1}{estimate_client_property_street_2}.pdf.</a></span><br/><br/><span style="font-size: 12pt;">If you have any questions, I\'m here to help!</span><br/><br/><span style="font-size: 12pt;">{email_signature}</span>','{companyname}','',0,1,0);

INSERT INTO tblemailtemplates (tenant_id, type, slug, language, name, subject,message,fromname,fromemail,plaintext,active,`order`,is_tenant_email_config_allowed,is_tenant )
SELECT t.id,s.type,s.slug,s.language,s.name,s.subject,s.message,s.fromname,s.fromemail,s.plaintext,s.active,s.order,0,0
FROM tbltenants t
JOIN tblemailtemplates_static s ON 1 = 1 AND s.slug ='quickbid-estimate-send-to-client';

INSERT INTO tblemailtemplates (tenant_id, type, slug, language, name, subject,message,fromname,fromemail,plaintext,active,`order`,is_tenant_email_config_allowed,is_tenant )
SELECT t.id,s.type,s.slug,s.language,s.name,s.subject,s.message,s.fromname,s.fromemail,s.plaintext,s.active,s.order,0,0
FROM tbltenants t
JOIN tblemailtemplates_static s ON 1 = 1 AND s.slug ='quickbid-estimate-already-send';

INSERT INTO tbloptions_static (name, value, autoload) VALUES('pdf_primary_color', '#c81e1e', 1);

INSERT INTO tbloptions (tenant_id, name, value, autoload)
SELECT t.id,s.name,s.value,s.autoload
FROM tbltenants t
JOIN tbloptions_static s ON 1 = 1 AND s.name ='pdf_primary_color';

INSERT INTO `tblemail_push_notification_config` (codename,is_active) VALUES ('quickbid_estimate_send_to_customer', 1), ('quickbid_estimate_send_to_customer_already_sent', 1);

