<?php
declare(strict_types=1);
require_once __DIR__ . '/../../../app/Models/Coa.php';
require_once __DIR__ . '/../../../app/Config/functions.php';
require_login();

header('Content-Type: application/json');
$model = new Coa();

$id = (int)($_POST['id'] ?? 0);
$data = [
  'account_code' => $_POST['account_code'] ?? '',
  'account_name' => $_POST['account_name'] ?? '',
  'account_type' => $_POST['account_type'] ?? '',
  'description'  => $_POST['description'] ?? ''
];

echo json_encode([
  'success' => $model->update($id, $data),
  'message' => 'Account updated successfully!'
]);
