<?php
require_once 'includes/db.php';
$lines = fetchAll("SELECT id, name FROM production_lines WHERE name IN ('AAA', 'Blue Frocks')");
foreach($lines as $l) {
    echo "Line: " . $l['name'] . "\n";
    $stages = fetchAll("SELECT ls.*, ws.name as stage_name FROM line_stages ls JOIN workflow_stages ws ON ls.workflow_stage_id = ws.id WHERE ls.production_line_id = ? ORDER BY ls.sort_order ASC", [$l['id']]);
    echo json_encode($stages) . "\n";
}
