CREATE TABLE tblbulk_client_invoice_payments (
	  tenant_id bigint(20) unsigned NOT NULL DEFAULT 1,
	  id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
      client_id bigint(20) unsigned DEFAULT NULL,
      status enum('pending','in_progress','completed','failed') NOT NULL DEFAULT 'pending',
      total_amount decimal(15,2) NOT NULL, 
      payment_mode varchar(40) DEFAULT NULL,
      date date NOT NULL,
      transaction_id varchar(191) DEFAULT NULL,
      note text NOT NULL,
      invoices_details longtext DEFAULT NULL,
      added_by bigint(20) unsigned NOT NULL,
      created_on datetime NOT NULL,
      updated_on datetime NOT NULL,      
	  PRIMARY KEY (id)
	) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;


INSERT INTO tblemailtemplates_static (type,slug,language,name,subject,message,fromname,fromemail,plaintext,active,`order`)
VALUES('invoice','invoice-bulk-payment-recorded','english','Invoice Bulk Payment Recorded (Sent to Client)','Invoice Bulk Payment Recorded','<span style="font-size: 12pt;">Hi {contact_firstname}, </span><br><br> <span style="font-size: 12pt;">We\'ve recorded a payment in the amount of {bulk_payment_total}.</span><br><br><span style="font-size: 12pt;">This payment was applied against the following invoices:</span><br><br><span style="font-size: 12pt;">{invoice_list}</span><br><span style="font-size: 12pt;"></span><br><br><span style="font-size: 12pt;">Thanks for your business!</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 = 'invoice-bulk-payment-recorded';
