/**
* Update English ticket notification templates with modern styling
*
* Updates ticket-assigned, ticket-updated, ticket-closed, and ticket-comment-added
* templates to match the modern visual design of ticket-created template.
*/
exports.up = async function(knex) {
console.log('Updating English ticket notification templates with modern styling...');
// Get notification subtypes
const subtypes = await knex('notification_subtypes')
.select('id', 'name')
.whereIn('name', [
'Ticket Assigned',
'Ticket Updated',
'Ticket Closed',
'Ticket Comment Added'
]);
const getSubtypeId = (name) => {
const subtype = subtypes.find(s => s.name === name);
if (!subtype) {
throw new Error(`Notification subtype '${name}' not found`);
}
return subtype.id;
};
// Update ticket-assigned template
await knex('system_email_templates')
.where({ name: 'ticket-assigned', language_code: 'en' })
.update({
subject: 'Ticket Assigned • {{ticket.title}} ({{ticket.priority}})',
html_content: `
|
Ticket Assigned
{{ticket.title}}
{{ticket.metaLine}}
|
|
You have been assigned to a ticket for {{ticket.clientName}}. Review the details below and take action.
| Priority |
{{ticket.priority}}
|
| Status |
{{ticket.status}} |
| Assigned By |
{{ticket.assignedBy}} |
| Assigned To |
{{ticket.assignedToName}}
{{ticket.assignedToEmail}}
|
| Requester |
{{ticket.requesterName}}
{{ticket.requesterContact}}
|
| Board |
{{ticket.board}} |
| Category |
{{ticket.categoryDetails}} |
| Location |
{{ticket.locationSummary}} |
Description
{{ticket.description}}
View Ticket
|
| Powered by Alga PSA • Keeping teams aligned |
|
`,
text_content: `
Ticket Assigned to You
{{ticket.metaLine}}
Assigned By: {{ticket.assignedBy}}
Priority: {{ticket.priority}}
Status: {{ticket.status}}
Assigned To: {{ticket.assignedDetails}}
Requester: {{ticket.requesterDetails}}
Board: {{ticket.board}}
Category: {{ticket.categoryDetails}}
Location: {{ticket.locationSummary}}
Description:
{{ticket.description}}
View ticket: {{ticket.url}}
`
});
// Update ticket-updated template
await knex('system_email_templates')
.where({ name: 'ticket-updated', language_code: 'en' })
.update({
subject: 'Ticket Updated • {{ticket.title}} ({{ticket.priority}})',
html_content: `
|
Ticket Updated
{{ticket.title}}
{{ticket.metaLine}}
|
|
A ticket for {{ticket.clientName}} has been updated. Review the changes below.
| Priority |
{{ticket.priority}}
|
| Status |
{{ticket.status}} |
| Updated By |
{{ticket.updatedBy}} |
| Assigned To |
{{ticket.assignedToName}}
{{ticket.assignedToEmail}}
|
| Requester |
{{ticket.requesterName}}
{{ticket.requesterContact}}
|
| Board |
{{ticket.board}} |
| Category |
{{ticket.categoryDetails}} |
| Location |
{{ticket.locationSummary}} |
Changes Made
{{ticket.changes}}
View Ticket
|
| Powered by Alga PSA • Keeping teams aligned |
|
`,
text_content: `
Ticket Updated
{{ticket.metaLine}}
Updated By: {{ticket.updatedBy}}
Priority: {{ticket.priority}}
Status: {{ticket.status}}
Assigned To: {{ticket.assignedDetails}}
Requester: {{ticket.requesterDetails}}
Board: {{ticket.board}}
Category: {{ticket.categoryDetails}}
Location: {{ticket.locationSummary}}
Changes Made:
{{ticket.changes}}
View ticket: {{ticket.url}}
`
});
// Update ticket-closed template
await knex('system_email_templates')
.where({ name: 'ticket-closed', language_code: 'en' })
.update({
subject: 'Ticket Closed • {{ticket.title}}',
html_content: `
|
Ticket Closed
{{ticket.title}}
{{ticket.metaLine}}
|
|
A ticket for {{ticket.clientName}} has been resolved and closed. Review the resolution details below.
| Status |
Closed
|
| Closed By |
{{ticket.closedBy}} |
| Assigned To |
{{ticket.assignedToName}}
{{ticket.assignedToEmail}}
|
| Requester |
{{ticket.requesterName}}
{{ticket.requesterContact}}
|
| Board |
{{ticket.board}} |
| Category |
{{ticket.categoryDetails}} |
| Location |
{{ticket.locationSummary}} |
Resolution
{{ticket.resolution}}
View Ticket
|
| Powered by Alga PSA • Keeping teams aligned |
|
`,
text_content: `
Ticket Closed
{{ticket.metaLine}}
Closed By: {{ticket.closedBy}}
Status: Closed
Assigned To: {{ticket.assignedDetails}}
Requester: {{ticket.requesterDetails}}
Board: {{ticket.board}}
Category: {{ticket.categoryDetails}}
Location: {{ticket.locationSummary}}
Resolution:
{{ticket.resolution}}
View ticket: {{ticket.url}}
`
});
// Update ticket-comment-added template
await knex('system_email_templates')
.where({ name: 'ticket-comment-added', language_code: 'en' })
.update({
subject: 'New Comment • {{ticket.title}}',
html_content: `
|
New Comment Added
{{ticket.title}}
{{ticket.metaLine}}
|
|
A new comment has been added to a ticket for {{ticket.clientName}}.
| Priority |
{{ticket.priority}}
|
| Status |
{{ticket.status}} |
| Comment By |
{{comment.author}} |
| Assigned To |
{{ticket.assignedToName}}
{{ticket.assignedToEmail}}
|
| Requester |
{{ticket.requesterName}}
{{ticket.requesterContact}}
|
| Board |
{{ticket.board}} |
| Category |
{{ticket.categoryDetails}} |
| Location |
{{ticket.locationSummary}} |
💬 Comment
{{comment.content}}
View Ticket
|
| Powered by Alga PSA • Keeping teams aligned |
|
`,
text_content: `
New Comment Added
{{ticket.metaLine}}
Comment By: {{comment.author}}
Priority: {{ticket.priority}}
Status: {{ticket.status}}
Assigned To: {{ticket.assignedDetails}}
Requester: {{ticket.requesterDetails}}
Board: {{ticket.board}}
Category: {{ticket.categoryDetails}}
Location: {{ticket.locationSummary}}
Comment:
{{comment.content}}
View ticket: {{ticket.url}}
`
});
console.log('✓ English ticket notification templates updated with modern styling');
};
exports.down = async function(knex) {
console.log('Reverting English ticket notification templates to basic styling...');
// Revert ticket-assigned template
await knex('system_email_templates')
.where({ name: 'ticket-assigned', language_code: 'en' })
.update({
subject: 'You have been assigned to ticket: {{ticket.title}}',
html_content: `
Ticket Assigned
You have been assigned to a ticket:
Ticket ID: {{ticket.id}}
Title: {{ticket.title}}
Priority: {{ticket.priority}}
Status: {{ticket.status}}
Assigned By: {{ticket.assignedBy}}
View Ticket
`,
text_content: `
Ticket Assigned
You have been assigned to a ticket:
Ticket ID: {{ticket.id}}
Title: {{ticket.title}}
Priority: {{ticket.priority}}
Status: {{ticket.status}}
Assigned By: {{ticket.assignedBy}}
View ticket at: {{ticket.url}}
`
});
// Revert ticket-updated template
await knex('system_email_templates')
.where({ name: 'ticket-updated', language_code: 'en' })
.update({
subject: 'Ticket Updated: {{ticket.title}}',
html_content: `
Ticket Updated
A ticket has been updated in your PSA system:
Ticket ID: {{ticket.id}}
Title: {{ticket.title}}
Changes: {{ticket.changes}}
Updated By: {{ticket.updatedBy}}
View Ticket
`,
text_content: `
Ticket Updated
A ticket has been updated in your PSA system:
Ticket ID: {{ticket.id}}
Title: {{ticket.title}}
Changes: {{ticket.changes}}
Updated By: {{ticket.updatedBy}}
View ticket at: {{ticket.url}}
`
});
// Revert ticket-closed template
await knex('system_email_templates')
.where({ name: 'ticket-closed', language_code: 'en' })
.update({
subject: 'Ticket Closed: {{ticket.title}}',
html_content: `
Ticket Closed
A ticket has been closed in your PSA system:
Ticket ID: {{ticket.id}}
Title: {{ticket.title}}
Resolution: {{ticket.resolution}}
Closed By: {{ticket.closedBy}}
View Ticket
`,
text_content: `
Ticket Closed
A ticket has been closed in your PSA system:
Ticket ID: {{ticket.id}}
Title: {{ticket.title}}
Resolution: {{ticket.resolution}}
Closed By: {{ticket.closedBy}}
View ticket at: {{ticket.url}}
`
});
// Revert ticket-comment-added template
await knex('system_email_templates')
.where({ name: 'ticket-comment-added', language_code: 'en' })
.update({
subject: 'New Comment on Ticket: {{ticket.title}}',
html_content: `
New Comment Added
A new comment has been added to ticket:
Ticket ID: {{ticket.id}}
Title: {{ticket.title}}
Comment By: {{comment.author}}
Comment:
View Ticket
`,
text_content: `
New Comment Added
A new comment has been added to ticket:
Ticket ID: {{ticket.id}}
Title: {{ticket.title}}
Comment By: {{comment.author}}
Comment:
{{comment.content}}
View ticket at: {{ticket.url}}
`
});
console.log('English ticket notification templates reverted');
};