INSERT INTO document_templates(document_type,name,page_format,orientation,template_html,custom_css,is_default,is_active)
SELECT 'ticket','Standard event ticket','A5','L','<div class="info-box"><strong>{{event_name}}</strong><br>Attendee: {{member_name}}</div><table><tr><th>Ticket code</th><td>{{ticket_code}}</td></tr><tr><th>Issued</th><td>{{issued_date}}</td></tr></table>','',1,1 WHERE NOT EXISTS(SELECT 1 FROM document_templates WHERE document_type='ticket');
INSERT INTO document_templates(document_type,name,page_format,orientation,template_html,custom_css,is_default,is_active)
SELECT 'receipt','Standard receipt','A4','P','<div class="info-box">Official payment receipt</div><table><tr><th>Member</th><td>{{member_name}}</td></tr><tr><th>Document</th><td>{{document_number}}</td></tr><tr><th>Issued</th><td>{{issued_date}}</td></tr></table>','',1,1 WHERE NOT EXISTS(SELECT 1 FROM document_templates WHERE document_type='receipt');
INSERT INTO document_templates(document_type,name,page_format,orientation,template_html,custom_css,is_default,is_active)
SELECT 'invoice','Standard invoice','A4','P','<div class="info-box">Invoice for {{member_name}}</div><table><tr><th>Document</th><td>{{document_number}}</td></tr><tr><th>Issued</th><td>{{issued_date}}</td></tr></table>','',1,1 WHERE NOT EXISTS(SELECT 1 FROM document_templates WHERE document_type='invoice');
INSERT INTO document_templates(document_type,name,page_format,orientation,template_html,custom_css,is_default,is_active)
SELECT 'quote','Standard quote','A4','P','<div class="info-box">Quotation prepared for {{member_name}}</div><p>Reference: {{document_number}}</p>','',1,1 WHERE NOT EXISTS(SELECT 1 FROM document_templates WHERE document_type='quote');
INSERT INTO document_templates(document_type,name,page_format,orientation,template_html,custom_css,is_default,is_active)
SELECT 'membership_id','Standard membership ID','85.6mm,54mm','L','<div class="member-card"><strong>{{member_name}}</strong><br>{{membership_id}}<br>{{cycle_name}}</div>','.member-card{border:1px solid #18181b;padding:8mm;font-size:11pt}',1,1 WHERE NOT EXISTS(SELECT 1 FROM document_templates WHERE document_type='membership_id');
INSERT INTO document_templates(document_type,name,page_format,orientation,template_html,custom_css,is_default,is_active)
SELECT 'membership_certificate','Standard membership certificate','A4','L','<div class="certificate"><p>This certifies that</p><h2>{{member_name}}</h2><p>is a member for {{cycle_name}}</p><p>{{membership_id}}</p></div>','.certificate{text-align:center;padding:25mm;border:2px solid #18181b}',1,1 WHERE NOT EXISTS(SELECT 1 FROM document_templates WHERE document_type='membership_certificate');
INSERT INTO document_templates(document_type,name,page_format,orientation,template_html,custom_css,is_default,is_active)
SELECT 'event_certificate','Standard event certificate','A4','L','<div class="certificate"><p>Certificate of participation</p><h2>{{member_name}}</h2><p>{{event_name}}</p><p>{{issued_date}}</p></div>','.certificate{text-align:center;padding:25mm;border:2px solid #18181b}',1,1 WHERE NOT EXISTS(SELECT 1 FROM document_templates WHERE document_type='event_certificate');
INSERT INTO document_templates(document_type,name,page_format,orientation,template_html,custom_css,is_default,is_active)
SELECT 'event_nametag','Standard event nametag','A6','P','<div class="nametag"><h2>{{member_name}}</h2><p>{{event_name}}</p><strong>{{ticket_code}}</strong></div>','.nametag{text-align:center;padding:12mm;border:1px solid #18181b}',1,1 WHERE NOT EXISTS(SELECT 1 FROM document_templates WHERE document_type='event_nametag');
INSERT IGNORE INTO document_template_assignments(template_id,scope_type,scope_id,document_type) SELECT id,'global',NULL,document_type FROM document_templates WHERE is_default=1;
