// ---------- Configuration ----------
// API endpoints - change if your actual method path differs
const JOBCARD_LIST_METHOD = "jct"; // user said api method: jct
// Using frappe client calls
// ---------- Utilities ----------
// ---------- App state ----------
let jobcards = []; // array of job card objects returned by jct
const runningTimers = {}; // map job_card_name -> interval id
// ---------- Fetch list ----------
// show loading
// call custom method
// ---------- Render UI ----------
stopAllTimers(); // clear timers before re-rendering
// calculate initial timer base:
// if actual_start_date present and status not Completed -> running
// Render action buttons
// If currently running, start timer
// allowed actions only for not finished
// Determine if currently running
// ---------- Timer logic ----------
// create an interval that updates the timer display every second
// clear existing
// ---------- Actions (Start / Pause / Resume / Stop) ----------
// Helper: load jobcard doc from server
// Helper: set fields on job card (uses set_value)
// get doc
// If already started, keep existing actual_start_date; else set it.
// clear actual_end_date
// refresh client state
// nothing to pause — just set On Hold
// compute elapsed between actual_start_date and now
// update doc: add to total_time_in_mins, clear actual_start_date, set status
// set actual_start_date to now and status to In Progress
// set status Completed, set actual_end_date, update total_time_in_mins, clear actual_start_date
// ---------- UI Events ----------
// initial fetch
// cleanup when unload
-->