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 associationsstep- Individual step records created during productionstep_target- Quantity targets for each step type per jobstep_type- Reference table for available step typessales_order- Sales order information from SAGE or manually createdstep_job_time- Time tracking records for jobs in progress
Key Relationships:
- Each
step_jobbelongs to onesales_order - Each
step_jobhas multiplestep_targetrecords (one per step type) - Each
step_jobhas multiplesteprecords (actual produced steps) - Each
stephas onestep_type - Each
step_jobcan have multiplestep_job_timerecords 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:
- SAGE Order Number maps to
sales_order.order_number - SAGE Customer Name maps to
sales_order.customer_name - SAGE Line Items map to
step_targetrecords (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 pagesapp/Controllers/Api/StepJob.php- Step Jobs APIapp/Controllers/Api/Step.php- Steps APIapp/Controllers/Api/StepType.php- Step Types API
Models:
app/Models/Step_job_model.phpapp/Models/Step_model.phpapp/Models/Step_target_model.phpapp/Models/Step_type_model.phpapp/Models/Sales_order_model.php
Views:
app/Views/step/step_jobs.phpapp/Views/step/step_in_progress.phpapp/Views/admin/edit_step.php
JavaScript:
public/js/step/step_jobs.jspublic/js/step/step_in_progress.js