Update: 2026-07-09 01:01:15

This commit is contained in:
Hamza-Ayed
2026-07-09 01:01:16 +03:00
parent 6fe1d665e7
commit ac0c343f18
4 changed files with 380 additions and 1 deletions
@@ -0,0 +1,57 @@
<?php
// ============================================================
// get_pricing_stability_log.php
// شاشة مراجعة محرك الثبات (Shadow Mode) — يعرض سجل التصنيفات
// والإجراءات المقترحة بدون ما يكون أي منها مطبّق فعلياً على kazan
// ============================================================
require_once __DIR__ . '/../../connect.php';
if ($role !== 'admin' && $role !== 'super_admin') {
http_response_code(403);
echo json_encode(['status' => 'failure', 'message' => 'Unauthorized access. Admin role required.']);
exit;
}
try {
$countryCode = filterRequest('country_code');
$limit = filterRequest('limit', 'int') ?? 100;
$sql = "SELECT * FROM pricing_stability_log";
$params = [];
if ($countryCode) {
$sql .= " WHERE country_code = :country";
$params[':country'] = strtoupper($countryCode);
}
$sql .= " ORDER BY evaluated_at DESC LIMIT :limit";
$stmt = $con->prepare($sql);
$stmt->bindValue(':limit', $limit, PDO::PARAM_INT);
foreach ($params as $key => $val) {
$stmt->bindValue($key, $val);
}
$stmt->execute();
$log = $stmt->fetchAll(PDO::FETCH_ASSOC);
// ملخص سريع لآخر تصنيف لكل دولة
$stmtLatest = $con->query("
SELECT l1.* FROM pricing_stability_log l1
INNER JOIN (
SELECT country_code, MAX(evaluated_at) AS max_time
FROM pricing_stability_log
GROUP BY country_code
) l2 ON l1.country_code = l2.country_code AND l1.evaluated_at = l2.max_time
");
$latestPerCountry = $stmtLatest->fetchAll(PDO::FETCH_ASSOC);
jsonSuccess([
'log' => $log,
'latest_per_country' => $latestPerCountry,
]);
} catch (Exception $e) {
error_log("[get_pricing_stability_log.php] Error: " . $e->getMessage());
jsonError("Failed to fetch pricing stability log: " . $e->getMessage());
}