Automatic Emails

STATS sends scheduled emails and alerts related to reporting and overdue devices. Use the controls below to explore examples. This page links back to the main Reports module.

← Back to Reporting
What gets emailed?
Weekly report email example

Weekly report email showing attachments and internal links.

Report emails subscription list UI

Admin list of recipients per year level with quick Unsubscribe/Delete actions.

Overdue device alert email (2-day)

Overdue alert after 2 days—gentle reminder to follow up.

Lock device escalation email (4-day)

Lock escalation at day 4—advises the device will be locked.

Scheduling & Queue (pseudocode)
// Nightly job
async function processEmailJobs(dateRange) {
  const years = [7,8,9,10,11,12];
  for (const y of years) {
    const files = await renderWeeklyFiles({ year_level: y, ...dateRange }); // -> { pdf, csv }
    const recipients = await listRecipients(y); // report_emails where subscribed=1
    for (const to of recipients) {
      await queue({ to, kind: 'weekly', files, dateRange });
    }
  }
  // Overdue + lock alerts
  const overdue = await findOverdue(2); // 2 days
  const locks   = await findOverdue(4); // 4 days
  for (const r of overdue) await queue({ to: r.notify, kind: 'overdue', data: r });
  for (const r of locks)   await queue({ to: r.notify, kind: 'lock',    data: r });
}
← Back to Reporting