<?php
// filepath: c:\Users\ASUS PN40\CDrive\xampp\business\ooh_project\handler\save_evaluation_json.php
$data = json_decode(file_get_contents('php://input'), true);
$site_id = $data['site_id'] ?? null;
$criteria = $data['criteria'] ?? null;
if ($site_id && $criteria) {
    $file = __DIR__ . "/../modules/json/site_evaluate.json";
    $all = [];
    if (file_exists($file)) {
        $all = json_decode(file_get_contents($file), true) ?: [];
    }
    $all[$site_id] = $criteria;
    file_put_contents($file, json_encode($all, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
    echo json_encode(['status'=>'ok']);
} else {
    echo json_encode(['status'=>'error']);
}