34627-vm/api/get_assets.php
Flatlogic Bot 8d0038be8c satu
2025-10-03 13:56:08 +00:00

34 lines
759 B
PHP

<?php
// api/get_assets.php
require_once __DIR__ . '/../db/config.php';
header('Content-Type: application/json');
try {
$pdo = getDbConnection();
$sql = "
SELECT
a.id,
a.kode_aset,
a.nama_aset,
kc.nama_kategori,
k.nama_kantor,
a.status
FROM aset a
JOIN kategori_aset kc ON a.id_kategori = kc.id
JOIN kantor k ON a.id_kantor_lokasi = k.id
ORDER BY a.created_at DESC
";
$stmt = $pdo->query($sql);
$assets = $stmt->fetchAll();
echo json_encode($assets);
} catch (Exception $e) {
http_response_code(500);
echo json_encode(['error' => 'Gagal mengambil data aset: ' . $e->getMessage()]);
}
?>