26 lines
699 B
PHP
26 lines
699 B
PHP
<?php
|
|
// api/get_options.php
|
|
|
|
require_once __DIR__ . '/../db/config.php';
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
try {
|
|
$pdo = getDbConnection();
|
|
|
|
$kategori_stmt = $pdo->query("SELECT id, nama_kategori FROM kategori_aset ORDER BY nama_kategori ASC");
|
|
$kategori = $kategori_stmt->fetchAll();
|
|
|
|
$kantor_stmt = $pdo->query("SELECT id, nama_kantor FROM kantor ORDER BY nama_kantor ASC");
|
|
$kantor = $kantor_stmt->fetchAll();
|
|
|
|
echo json_encode([
|
|
'kategori' => $kategori,
|
|
'kantor' => $kantor
|
|
]);
|
|
|
|
} catch (Exception $e) {
|
|
http_response_code(500);
|
|
echo json_encode(['error' => 'Gagal mengambil data options: ' . $e->getMessage()]);
|
|
}
|
|
?>
|