<?php
require_once '../config/config.php';
if (!isset($_SESSION['user_id'])) { exit; }

header('Content-Type: application/json');
 $mesin_id = $_GET['mesin_id'] ?? 0;

 $stmt = $pdo->prepare("SELECT * FROM bagian_mesin WHERE mesin_id = ? ORDER BY nama_bagian ASC");
 $stmt->execute([$mesin_id]);
 $data = $stmt->fetchAll(PDO::FETCH_ASSOC);

echo json_encode($data);
?>