<?php  if (!defined('DASHBOARD_ROOT')) { http_response_code(403); exit; } function renderStageControls(int $orderId): string { $stages=[2002=>"Paid",2003=>"Processing",2004=>"Packed",2005=>"Shipped",2006=>"Delivered"]; $order=Database::fetchOne("SELECT id,status_code FROM orders WHERE id=:id",[":id"=>$orderId]); if(!$order) return ""; $currentCode=(int)$order["status_code"]; $html="<div class=\"stage-controls\">"; foreach($stages as $code=>$label){ $active=$code===$currentCode?"active":""; $html.="<button class=\"stage-btn {$active}\" data-action=\"updateStage\" data-order=\"{$orderId}\" data-stage=\"{$code}\">{$label}</button>"; } $html.="</div>"; return $html; } 