Reports Module

Generate weekly or ad‑hoc summaries covering borrow activity, outstanding slips, current assignments, and late returns. Below is a preview image of a generated PDF report (first pages), plus an embedded viewer if you prefer to scroll the PDF.

Report preview Report preview
// PSEUDOCODE — how a weekly report is generated (frontend-friendly)

async function runWeeklyReport(filters) {
  // 1) Fetch data slices used in the PDF
  const summary   = await fetchJson('/api/reports/summary', filters);
  const slipsIn   = await fetchJson('/api/reports/slips?status=validated', filters);
  const slipsOut  = await fetchJson('/api/reports/slips?status=pending', filters);
  const assigned  = await fetchJson('/api/reports/assignments?open=true', filters);
  const history   = await fetchJson('/api/reports/history', filters);

  // 2) Build a single payload (server can render PDF via TCPDF)
  const payload = { summary, slipsIn, slipsOut, assigned, history, filters };

  // 3) Ask server to render and store PDF + CSV
  const res = await fetch('/api/reports/render', {
    method: 'POST', headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify(payload)
  });
  return await res.json(); // => {{ filenamePdf, filenameCsv, id }}
}

function fetchJson(url, q) {
  const full = url + '&' + new URLSearchParams(q ?? {}).toString();
  return fetch(full).then(r => r.json());
}

Tip: store generated files in reports table with generated_by and filters_used for audit.

Open PDF

More about Automatic Emails