Skip to main content

Pool Steps

Database Schema

The Pool Steps system relies on several interconnected database tables:

Primary Tables:

  • step_job - Stores Pool Step job records with sales order associations
  • step - Individual step records created during production
  • step_target - Quantity targets for each step type per job
  • step_type - Reference table for available step types
  • sales_order - Sales order information from SAGE or manually created
  • step_job_time - Time tracking records for jobs in progress

Key Relationships:

  • Each step_job belongs to one sales_order
  • Each step_job has multiple step_target records (one per step type)
  • Each step_job has multiple step records (actual produced steps)
  • Each step has one step_type
  • Each step_job can have multiple step_job_time records for tracking work sessions

Logic & Integrations

Time Tracking Implementation

The 5-second auto-update is implemented using JavaScript intervals:

setInterval(function() {
if (!isPaused) {
updateElapsedTime(jobId);
}
}, 5000);
  • The timer continues running even if the user navigates away (tracked in the database via step_job_time).
  • When the user returns to Job In Progress page, elapsed time resumes from the database value.
  • Multiple users cannot work on the same job simultaneously.

SEI Serial Number System

  • Serial numbers must be unique within each job (not globally unique).
  • A database constraint prevents duplicate serials within the same step_job_id.
  • Frontend validation (/api/steps/...) provides immediate feedback before database save.

Step Target Validation

  • The system allows job completion even if targets are not fully met (it provides a warning if actual counts are less than targets).
  • Production realities may require flexibility (material issues, order changes), so targets act as a guideline rather than a strict constraint.

SAGE Integration Details

The system periodically imports sales orders from SAGE ERP:

  1. SAGE Order Number maps to sales_order.order_number
  2. SAGE Customer Name maps to sales_order.customer_name
  3. SAGE Line Items map to step_target records (parsed by step type).

If an imported job is manually deleted by an admin, but the SAGE order remains active and not completed in SAGE, the next sync cycle will recreate the job in the Shelter app.


Code File Locations

Controllers:

  • app/Controllers/Step.php - Main controller for Pool Steps pages
  • app/Controllers/Api/StepJob.php - Step Jobs API
  • app/Controllers/Api/Step.php - Steps API
  • app/Controllers/Api/StepType.php - Step Types API

Models:

  • app/Models/Step_job_model.php
  • app/Models/Step_model.php
  • app/Models/Step_target_model.php
  • app/Models/Step_type_model.php
  • app/Models/Sales_order_model.php

Views:

  • app/Views/step/step_jobs.php
  • app/Views/step/step_in_progress.php
  • app/Views/admin/edit_step.php

JavaScript:

  • public/js/step/step_jobs.js
  • public/js/step/step_in_progress.js