27 lines
899 B
PHP
27 lines
899 B
PHP
<?php
|
|
header('Content-Type: application/json');
|
|
require_once __DIR__ . '/../db/config.php';
|
|
require_once __DIR__ . '/../includes/functions.php';
|
|
|
|
$customer_id = isset($_GET['customer_id']) ? intval($_GET['customer_id']) : null;
|
|
|
|
if (!$customer_id) {
|
|
echo json_encode(['success' => false, 'error' => 'Customer ID required']);
|
|
exit;
|
|
}
|
|
|
|
try {
|
|
$pdo = db();
|
|
$stmt = $pdo->prepare("SELECT id, points_change, reason, order_id, created_at
|
|
FROM loyalty_points_history
|
|
WHERE customer_id = ?
|
|
ORDER BY created_at DESC
|
|
LIMIT 50");
|
|
$stmt->execute([$customer_id]);
|
|
$history = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
echo json_encode(['success' => true, 'history' => $history]);
|
|
} catch (Exception $e) {
|
|
echo json_encode(['success' => false, 'error' => $e->getMessage()]);
|
|
}
|