TGM Manager provides data export capabilities allowing you to export maintenance data to Excel, CSV, and PDF formats for reporting, analysis, and compliance purposes.

Overview

The export system supports:

  • Excel Export - Full-featured spreadsheets with formatting (.xlsx)
  • CSV Export - Simple comma-separated values for data processing
  • PDF Export - Formatted reports for printing and distribution
  • Selective Export - Export all or selected records
  • Multiple Entity Types - Export inspections, interventions, failures, components, units

Supported Formats

Format Extension Use Case
Excel .xlsx Analysis in spreadsheet software, data manipulation
CSV .csv Data import/export, processing with scripts
PDF .pdf Printing, distribution, archival

REST API

Inspection Exports

Export to Excel

GET /export/inspections/excel
GET /export/inspections/excel?ids=1,2,3,4,5

Parameters:

Parameter Type Required Description
ids array No Specific inspection IDs to export (empty = all)

Response: Binary file download

Filename: inspections_export_YYYYMMDD_HHmmss.xlsx

Export to CSV

GET /export/inspections/csv
GET /export/inspections/csv?ids=1,2,3

Response: Binary file download

Filename: inspections_export_YYYYMMDD_HHmmss.csv

Export to PDF

GET /export/inspections/pdf
GET /export/inspections/pdf?ids=1,2,3

Response: Binary file download

Filename: inspections_report_YYYYMMDD_HHmmss.pdf

Required Role: ADMIN, MANAGER, or TECHNICIAN

Intervention Exports

Export to Excel

GET /export/interventions/excel
GET /export/interventions/excel?ids=10,20,30

Export to CSV

GET /export/interventions/csv

Export to PDF

GET /export/interventions/pdf

Required Role: ADMIN, MANAGER, or TECHNICIAN

Failure Exports

Export to Excel

GET /export/failures/excel
GET /export/failures/excel?ids=100,101,102

Export to CSV

GET /export/failures/csv

Export to PDF

GET /export/failures/pdf

Required Role: ADMIN, MANAGER, or TECHNICIAN

Component Exports

Export to Excel

GET /export/components/excel
GET /export/components/excel?ids=1,2,3

Required Role: ADMIN, MANAGER, or TECHNICIAN

Unit Exports

Export to Excel

GET /export/units/excel
GET /export/units/excel?ids=5,6,7

Required Role: ADMIN, MANAGER, or TECHNICIAN

Export Contents

Inspections Export

Column Description
ID Inspection identifier
Component Related component name
Unit Related unit name
Location Location name
Inspection Date When inspection was performed
Inspector User who performed inspection
Status Inspection status
Type Inspection type
Findings Inspection findings/notes
Recommendations Recommended actions
Next Due Date Next scheduled inspection
Created At Record creation timestamp

Interventions Export

Column Description
ID Intervention identifier
Component Related component name
Type Intervention type
Start Date When intervention started
End Date When intervention completed
Technician Assigned technician
Status Intervention status
Description Work performed
Parts Used Parts/materials used
Labor Hours Total labor hours
Cost Total cost

Failures Export

Column Description
ID Failure identifier
Component Failed component
Unit Related unit
Failure Date When failure occurred
Detected By User who detected
Type Failure type
Severity Failure severity
Description Failure description
Root Cause Identified root cause
Resolution How it was resolved
Downtime Hours Total downtime

Components Export

Column Description
ID Component identifier
Name Component name
Code Component code
Unit Parent unit
Location Location
Type Component type
Manufacturer Manufacturer name
Model Model number
Serial Number Serial number
Install Date Installation date
Status Current status
Last Inspection Last inspection date
Next Maintenance Next scheduled maintenance

Units Export

Column Description
ID Unit identifier
Name Unit name
Code Unit code
Location Location
Type Unit type
Status Current status
Component Count Number of components
Created At Record creation date

Usage Examples

Export All Inspections to Excel

curl -X GET "http://localhost:1337/export/inspections/excel" \
  -H "Authorization: Bearer $JWT" \
  -o inspections_export.xlsx

Export Selected Failures to CSV

curl -X GET "http://localhost:1337/export/failures/csv?ids=101,102,103,104" \
  -H "Authorization: Bearer $JWT" \
  -o selected_failures.csv

Generate PDF Report

curl -X GET "http://localhost:1337/export/interventions/pdf" \
  -H "Authorization: Bearer $JWT" \
  -o interventions_report.pdf

JavaScript Example

// Download Excel export
async function exportInspections(inspectionIds) {
  const params = inspectionIds ? `?ids=${inspectionIds.join(',')}` : '';

  const response = await fetch(`/export/inspections/excel${params}`, {
    headers: {
      'Authorization': `Bearer ${token}`
    }
  });

  if (response.ok) {
    const blob = await response.blob();
    const url = window.URL.createObjectURL(blob);
    const a = document.createElement('a');
    a.href = url;
    a.download = `inspections_${new Date().toISOString().slice(0,10)}.xlsx`;
    a.click();
    window.URL.revokeObjectURL(url);
  }
}

Excel Features

Excel exports include:

  • Formatted headers - Bold column headers with background color
  • Auto-fitted columns - Column widths adjusted to content
  • Date formatting - Dates displayed in readable format
  • Number formatting - Numbers formatted appropriately
  • Frozen header row - Header stays visible when scrolling
  • Filtered data - Excel filter dropdowns enabled

PDF Features

PDF exports include:

  • Company header - Company name and logo
  • Report title - Entity type and date range
  • Formatted tables - Clean, readable tables
  • Page numbers - Footer with page numbers
  • Generation timestamp - When report was generated
  • Summary statistics - Totals and counts

Best Practices

  1. Export selectively - Export only needed records for faster downloads
  2. Use appropriate format - Excel for analysis, PDF for distribution
  3. Regular backups - Use exports for data backup purposes
  4. Compliance exports - Schedule regular exports for audit trails
  5. Large datasets - Consider pagination for very large exports

Error Handling

Status Description
200 Success - file download
401 Unauthorized - invalid or missing token
403 Forbidden - insufficient permissions
404 Not found - specified IDs don't exist
500 Server error - export generation failed

File Naming Convention

Files are automatically named with the pattern:

{entity_type}_{type}_{YYYYMMDD}_{HHmmss}.{extension}

Examples: - inspections_export_20240131_143022.xlsx - failures_export_20240131_143022.csv - interventions_report_20240131_143022.pdf