Work Order Scheduling Page
https://chatgpt.com/canvas/shared/692c52e6c7708191b529965e0b29c16b - Clickable

1. Purpose & Scope
The Work Order Scheduling Page is designed to allow planners and production supervisors to allocate Work Orders to production lines at specific time periods. The page supports:
Viewing Unscheduled and Scheduled Work Orders.
Assigning a Work Order to a Line for a specific time window.
Adjusting scheduling quantities for partially scheduled Work Orders.
Removing (unscheduling) Work Orders that have not yet started.
Enforcing constraints such as preventing unscheduling for schedules that already have run records.
This page directly interacts with the following backend schema elements:
work_order
schedule
production_run (read-only, for determining if unscheduling is allowed)
line (Line master)
2. Page Layout Overview
The Scheduling Page has four major sections:
Header — Name and purpose of the page.
Filters & Gantt Placeholder — Multi-select Line filter, fixed date window, and Gantt visualization placeholder.
Unscheduled / Scheduled Tabs — Tables showing available and currently scheduled Work Orders.
Schedule Work Order Popup — Form to insert a schedule record.
This matches the UI mockup implemented in Canvas (Nova Mfg Scheduling Tab Mockup).
3. Filters & Gantt Timeline

3.1 Line Filter (Multi-Select)

A multi-select button group displays all available production lines:
Line 1 – Filling
Line 2 – Packing
Line 3 – Assembly
Behaviour:
Select All by default.
Users may deselect lines to focus on specific areas.
This filter is applied to both the Gantt placeholder and the Scheduled WO table.
Backend Effect:
Multi-line filter is applied in Named Queries to restrict the schedule query:
WHERE schedule.line_id = ANY(:selected_line_ids)
3.2 Date Window (Fixed +3 / -3 days)
Instead of choosing a date range, planners work within a fixed schedule window relative to the current date:
Start: Today - 3 days
End: Today + 3 days
Displayed read-only in the UI.
Backend Effect:
All schedule queries must filter by this window:
WHERE schedule.start_datetime BETWEEN :window_start AND :window_end
3.3 Gantt Placeholder
A placeholder is displayed. In the final implementation, this will be replaced with:
Ignition Perspective Timeline/Gantt implementation
Or a custom SVG/canvas component driven by the schedule query
For now, the placeholder reflects the filtered date range and selected lines visually.
4. Unscheduled / Scheduled Work Order Tables
4.1 Tab Structure
Two tabs:
Unscheduled
Scheduled
Users switch between them using the tab header.
Only one table is visible at any time.
4.2 Unscheduled Table

Columns:
| Column | Description |
| Work Order | Work Order number |
| Product | Product Code |
| Total Qty | Original work order quantity |
| Unscheduled Qty | Remaining quantity that is not yet scheduled |
| Action | “Schedule” button |
Behaviour:
If the user clicks Schedule, a popup opens (Section 5).
If Unscheduled Qty = 0, the row is hidden (or disabled).
Backend Logic:
Unscheduled Work Orders are derived, not stored separately:
SELECT wo.id, wo.wo_code, wo.product_code, wo.total_qty, (wo.total_qty - COALESCE(SUM(schedule.quantity), 0)) AS unscheduled_qty FROM work_order wo LEFT JOIN schedule ON schedule.work_order_id = wo.id GROUP BY wo.id HAVING (wo.total_qty - COALESCE(SUM(schedule.quantity), 0)) > 0;
4.3 Scheduled Table

Columns:
| Column | Description |
| Work Order | Work Order number |
| Product | Product Code |
| Line | Assigned production line |
| Scheduled Qty | Allocated schedule quantity |
| Produced Qty | Quantity produced (from production_run) |
| Status | Not Started / Started / Completed |
| Action | Unschedule button (if allowed) |
Behaviour:
Unschedule button is enabled only when Status = Not Started.
If Status = Started / Completed → button disabled.
Backend Constraints:
A schedule record cannot be deleted if a run already exists:
SELECT COUNT(*) FROM production_run WHERE schedule_id = :schedule_id;
If count > 0 → NO UNSCHEDULE.
5. Schedule Work Order Popup
This popup appears when user clicks Schedule on an Unscheduled WO.
5.1 Fields
| Field | User Input | Backend Field |
| Line | Dropdown | schedule.line_id |
| Start datetime | Datetime input | schedule.start_datetime |
| End datetime | Datetime input | schedule.end_datetime |
| Scheduled quantity | Number | schedule.quantity |
Default Scheduled Quantity = UnscheduledQty.
Example top label:
WO-Demo1 · P-1001 — Unscheduled Qty 101

5.2 Insert Schedule Logic
When user submits:
Insert new row into schedule table:
INSERT INTO schedule ( work_order_id, line_id, quantity, start_datetime, end_datetime ) VALUES (:wo_id, :line_id, :qty, :start_dt, :end_dt) RETURNING id;
Recalculate UnscheduledQty:
UPDATE work_order SET unscheduled_qty = total_qty - ( SELECT SUM(quantity) FROM schedule WHERE work_order_id = :wo_id );
If unscheduled_qty = 0 → Work Order disappears from Unscheduled tab.
6. Unschedule Behaviour
Triggered from Scheduled tab.
6.1 Valid Unschedule (Not Started)

If:
schedule.status = “Not Started”
AND no production_run exists referencing the schedule
Then backend:
DELETE FROM schedule WHERE id = :schedule_id;
After deletion, the WO appears again in Unscheduled with updated UnscheduledQty.
6.2 Invalid Unschedule (Started or Completed)
If schedule.status ≠ “Not Started” OR run exists:
Block deletion.
Show validation message (Ignition message box):
“Cannot unschedule. A production run has already begun for this schedule.”
7. Backend Flow Summary
| Action | DB Operation | UI Result |
| Schedule WO | Insert schedule row | WO decreases in Unscheduled and appears in Scheduled |
| Partial Scheduling | Insert with qty < unscheduled_qty | Remaining unscheduled qty decreases |
| Full Scheduling | Insert with qty = unscheduled_qty | WO disappears from Unscheduled |
| Unschedule (valid) | Delete schedule row | WO reappears in Unscheduled |
| Unschedule (invalid) | No-op | Button disabled or user warned |
8. Ignition Implementation Requirements
8.1 Named Queries
A. Get Unscheduled Work Orders
Dynamic filter: line filter not needed here.
B. Get Scheduled Work Orders
Filters required:
selected lines
window_start, window_end
C. Insert Schedule
Parameters:
wo_id
line_id
quantity
start_datetime
end_datetime
D. Delete Schedule
Parameter:
schedule_id
backend must enforce “cannot delete if run exists”
8.2 Perspective Components
Multi-select Lines → Repeated buttons or multi-select dropdown
Gantt → placeholder now, real component later
Tab Container → Unscheduled / Scheduled
Two Perspective Tables
Popup View for schedule form
9. Future Enhancements (Optional)
Drag-and-drop Gantt scheduling
Schedule conflict detection
Auto-split scheduling for overlapping windows
Integration with APS / planning system
Real-time production load visualization per line
10. Summary
This Work Order Scheduling page provides a clean, intuitive interface for planning production in Nova MFG.
The behaviour fully matches the expected backend logic:
Schedules are explicit database records.
Unscheduled WOs are dynamically calculated.
Unscheduling is strictly controlled based on run existence.
UI behaviour mirrors database state.