prepare("DELETE FROM ratings"); if ($stmt->execute()) { $success_msg = __('ratings_cleared'); } else { $error_msg = __('error_clearing_ratings'); } } $from_date = $_GET['from_date'] ?? date('Y-m-01'); $to_date = $_GET['to_date'] ?? date('Y-m-t'); $type_filter = $_GET['type'] ?? 'all'; $branch_filter = $_GET['branch_id'] ?? 'all'; $where = "WHERE DATE(ratings.created_at) BETWEEN ? AND ?"; $params = [$from_date, $to_date]; if ($type_filter !== 'all') { $where .= " AND ratings.rating_type = ?"; $params[] = $type_filter; } if ($branch_filter !== 'all') { $where .= " AND ratings.branch_id = ?"; $params[] = $branch_filter; } // Fetch branches for filter and modal $branches_stmt = db()->query("SELECT id, name_en, name_ar FROM branches ORDER BY name_en"); $all_branches = $branches_stmt->fetchAll(PDO::FETCH_ASSOC); // Summary Stats $stmt = db()->prepare(" SELECT COUNT(*) as total_ratings, AVG(ratings.rating_value) as avg_rating FROM ratings LEFT JOIN branches b ON ratings.branch_id = b.id $where "); $stmt->execute($params); $stats = $stmt->fetch(PDO::FETCH_ASSOC); $total_ratings = $stats['total_ratings'] ?: 0; $avg_rating = round($stats['avg_rating'] ?: 0, 1); // Detail Records $stmt = db()->prepare(" SELECT ratings.*, b.name_en AS branch_name_en, b.name_ar AS branch_name_ar FROM ratings LEFT JOIN branches b ON ratings.branch_id = b.id $where ORDER BY ratings.created_at DESC "); $stmt->execute($params); $ratings = $stmt->fetchAll(PDO::FETCH_ASSOC); ?>
| = __('date') ?> | = __('branch') ?> | = __('rating_type') ?> | = __('rating') ?> | = __('comment') ?> |
|---|---|---|---|---|
| = __('no_data_available') ?? 'No data available' ?> | ||||
| = date('Y-m-d H:i', strtotime($r['created_at'])) ?> | = htmlspecialchars(is_arabic() ? ($r['branch_name_ar'] ?? '-') : ($r['branch_name_en'] ?? '-')) ?> | = __('staff') ?> = __('service') ?> | = htmlspecialchars($r['comment']) ?> | |