<?php
session_start();
header('Content-Type: application/json');
require_once '../config/auth.php';
if(!isset($_SESSION['user_id'])) die(json_encode(['status'=>'error']));
include '../config/database.php';

$db = new Database();
$conn = $db->getConnection();

$sql = "SELECT *, DATE_FORMAT(tgl_upload, '%d %b %Y %H:%i') as tgl_upload FROM struktur_organisasi ORDER BY id DESC";
$data = $conn->query($sql)->fetchAll(PDO::FETCH_ASSOC);

echo json_encode(['status'=>'success','data'=>$data]);
?>