diff --git a/includes/lang.php b/includes/lang.php index 546a44d..e2da2e4 100644 --- a/includes/lang.php +++ b/includes/lang.php @@ -27,6 +27,9 @@ $translations = [ 'ratings' => 'Ratings', 'staff_rating' => 'Staff Rating', 'service_rating' => 'Service Rating', + 'branch_links' => 'Branch Links', + 'copy_link' => 'Copy Link', + 'link_copied' => 'Copied!', 'rating' => 'Rating', 'comment' => 'Comment', 'rating_type' => 'Type', @@ -301,6 +304,9 @@ $translations = [ 'ratings' => 'التقييمات', 'staff_rating' => 'تقييم الموظفين', 'service_rating' => 'تقييم الخدمة', + 'branch_links' => 'روابط الفروع', + 'copy_link' => 'نسخ الرابط', + 'link_copied' => 'تم النسخ!', 'rating' => 'التقييم', 'comment' => 'تعليق', 'rating_type' => 'النوع', diff --git a/ratings.php b/ratings.php index 16899dd..04a4020 100644 --- a/ratings.php +++ b/ratings.php @@ -17,21 +17,32 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST[' $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(created_at) BETWEEN ? AND ?"; +$where = "WHERE DATE(ratings.created_at) BETWEEN ? AND ?"; $params = [$from_date, $to_date]; if ($type_filter !== 'all') { - $where .= " AND rating_type = ?"; + $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(rating_value) as avg_rating + AVG(ratings.rating_value) as avg_rating FROM ratings + LEFT JOIN branches b ON ratings.branch_id = b.id $where "); $stmt->execute($params); @@ -42,10 +53,11 @@ $avg_rating = round($stats['avg_rating'] ?: 0, 1); // Detail Records $stmt = db()->prepare(" - SELECT * + 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 created_at DESC + ORDER BY ratings.created_at DESC "); $stmt->execute($params); $ratings = $stmt->fetchAll(PDO::FETCH_ASSOC); @@ -70,9 +82,9 @@ $ratings = $stmt->fetchAll(PDO::FETCH_ASSOC);

- - - +
@@ -84,14 +96,25 @@ $ratings = $stmt->fetchAll(PDO::FETCH_ASSOC);
-
+
-
+
+
+ + +
-
+
@@ -155,6 +178,7 @@ $ratings = $stmt->fetchAll(PDO::FETCH_ASSOC); + @@ -163,12 +187,13 @@ $ratings = $stmt->fetchAll(PDO::FETCH_ASSOC); - + + @@ -193,4 +218,81 @@ $ratings = $stmt->fetchAll(PDO::FETCH_ASSOC);
- \ No newline at end of file + + + + + +