update rating
This commit is contained in:
parent
d76a592792
commit
b1bb8c3b26
15
db/migrations/19_add_ratings.sql
Normal file
15
db/migrations/19_add_ratings.sql
Normal file
@ -0,0 +1,15 @@
|
||||
CREATE TABLE IF NOT EXISTS ratings (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
branch_id INT NULL,
|
||||
company_id INT NULL,
|
||||
rating_type ENUM('staff', 'service') NOT NULL,
|
||||
rating_value INT NOT NULL,
|
||||
comment TEXT,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (branch_id) REFERENCES branches(id) ON DELETE SET NULL,
|
||||
FOREIGN KEY (company_id) REFERENCES companies(id) ON DELETE SET NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
INSERT IGNORE INTO user_permissions (user_id, page, can_view, can_add, can_edit, can_delete)
|
||||
SELECT id, 'ratings.php', 1, 1, 1, 1
|
||||
FROM users WHERE role = 'super_admin';
|
||||
@ -285,6 +285,15 @@ if ($current_user_id && $current_page !== 'login.php' && $current_page !== 'logo
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (has_permission('view', 'ratings.php')): ?>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link <?= basename($_SERVER['PHP_SELF']) == 'ratings.php' ? 'active' : '' ?>" href="ratings.php">
|
||||
<i class="bi bi-star"></i>
|
||||
<?= __('ratings') ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (has_permission('view', 'items.php')): ?>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link <?= basename($_SERVER['PHP_SELF']) == 'items.php' ? 'active' : '' ?>" href="items.php">
|
||||
|
||||
@ -16,6 +16,26 @@ if (isset($_GET['lang'])) {
|
||||
|
||||
$translations = [
|
||||
'en' => [
|
||||
|
||||
'how_rate_staff' => 'How would you rate our staff?',
|
||||
'how_rate_service' => 'How would you rate our services?',
|
||||
'comment_placeholder' => 'Tell us about your experience...',
|
||||
'submit_another' => 'Submit Another Rating',
|
||||
'provide_valid_rating' => 'Please provide a valid rating (1-5).',
|
||||
'error_saving_rating' => 'Error saving rating. Please try again.',
|
||||
'optional' => 'Optional',
|
||||
'ratings' => 'Ratings',
|
||||
'staff_rating' => 'Staff Rating',
|
||||
'service_rating' => 'Service Rating',
|
||||
'rating' => 'Rating',
|
||||
'comment' => 'Comment',
|
||||
'rating_type' => 'Type',
|
||||
'staff' => 'Staff',
|
||||
'service' => 'Service',
|
||||
'average_rating' => 'Average Rating',
|
||||
'total_ratings' => 'Total Ratings',
|
||||
'submit_rating' => 'Submit Rating',
|
||||
'rating_submitted' => 'Thank you! Your rating has been submitted.',
|
||||
'dashboard' => 'Dashboard',
|
||||
'pos' => 'POS',
|
||||
'orders' => 'Orders',
|
||||
@ -256,6 +276,26 @@ $translations = [
|
||||
'confirm_delete' => 'Are you sure you want to delete this?',
|
||||
],
|
||||
'ar' => [
|
||||
|
||||
'how_rate_staff' => 'كيف تقيم موظفينا؟',
|
||||
'how_rate_service' => 'كيف تقيم خدماتنا؟',
|
||||
'comment_placeholder' => 'أخبرنا عن تجربتك...',
|
||||
'submit_another' => 'إرسال تقييم آخر',
|
||||
'provide_valid_rating' => 'يرجى تقديم تقييم صحيح (1-5).',
|
||||
'error_saving_rating' => 'حدث خطأ أثناء حفظ التقييم. يرجى المحاولة مرة أخرى.',
|
||||
'optional' => 'اختياري',
|
||||
'ratings' => 'التقييمات',
|
||||
'staff_rating' => 'تقييم الموظفين',
|
||||
'service_rating' => 'تقييم الخدمة',
|
||||
'rating' => 'التقييم',
|
||||
'comment' => 'تعليق',
|
||||
'rating_type' => 'النوع',
|
||||
'staff' => 'موظف',
|
||||
'service' => 'خدمة',
|
||||
'average_rating' => 'متوسط التقييم',
|
||||
'total_ratings' => 'إجمالي التقييمات',
|
||||
'submit_rating' => 'إرسال التقييم',
|
||||
'rating_submitted' => 'شكرًا لك! تم إرسال تقييمك.',
|
||||
'dashboard' => 'لوحة القيادة',
|
||||
'pos' => 'نقطة البيع',
|
||||
'orders' => 'الطلبات',
|
||||
|
||||
166
ratings.php
Normal file
166
ratings.php
Normal file
@ -0,0 +1,166 @@
|
||||
<?php
|
||||
$title = 'ratings';
|
||||
require_once __DIR__ . '/includes/header.php';
|
||||
|
||||
$from_date = $_GET['from_date'] ?? date('Y-m-01');
|
||||
$to_date = $_GET['to_date'] ?? date('Y-m-t');
|
||||
$type_filter = $_GET['type'] ?? 'all';
|
||||
|
||||
$where = "WHERE DATE(created_at) BETWEEN ? AND ?";
|
||||
$params = [$from_date, $to_date];
|
||||
|
||||
if ($type_filter !== 'all') {
|
||||
$where .= " AND rating_type = ?";
|
||||
$params[] = $type_filter;
|
||||
}
|
||||
|
||||
// Summary Stats
|
||||
$stmt = db()->prepare("
|
||||
SELECT
|
||||
COUNT(*) as total_ratings,
|
||||
AVG(rating_value) as avg_rating
|
||||
FROM ratings
|
||||
$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 *
|
||||
FROM ratings
|
||||
$where
|
||||
ORDER BY created_at DESC
|
||||
");
|
||||
$stmt->execute($params);
|
||||
$ratings = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
?>
|
||||
|
||||
<div class="container-fluid py-4">
|
||||
<div class="row mb-4 align-items-center">
|
||||
<div class="col">
|
||||
<h1 class="h3 mb-0 text-gray-800"><?= __('ratings') ?></h1>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<a href="staff_rating.php" target="_blank" class="btn btn-sm btn-outline-primary"><i class="bi bi-box-arrow-up-right"></i> <?= __('staff_rating') ?> Page</a>
|
||||
<a href="service_rating.php" target="_blank" class="btn btn-sm btn-outline-primary"><i class="bi bi-box-arrow-up-right"></i> <?= __('service_rating') ?> Page</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Filter Card -->
|
||||
<div class="card shadow-sm mb-4">
|
||||
<div class="card-body">
|
||||
<form method="GET" class="row gx-3 gy-2 align-items-center">
|
||||
<div class="col-sm-3">
|
||||
<label class="visually-hidden"><?= __('from_date') ?></label>
|
||||
<input type="date" class="form-control" name="from_date" value="<?= htmlspecialchars($from_date) ?>">
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
<label class="visually-hidden"><?= __('to_date') ?></label>
|
||||
<input type="date" class="form-control" name="to_date" value="<?= htmlspecialchars($to_date) ?>">
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
<label class="visually-hidden"><?= __('rating_type') ?></label>
|
||||
<select class="form-select" name="type">
|
||||
<option value="all" <?= $type_filter == 'all' ? 'selected' : '' ?>><?= __('all') ?></option>
|
||||
<option value="staff" <?= $type_filter == 'staff' ? 'selected' : '' ?>><?= __('staff') ?></option>
|
||||
<option value="service" <?= $type_filter == 'service' ? 'selected' : '' ?>><?= __('service') ?></option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
<button type="submit" class="btn btn-primary w-100"><i class="bi bi-search"></i> <?= __('filter') ?></button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Stats Cards -->
|
||||
<div class="row mb-4">
|
||||
<div class="col-xl-3 col-md-6 mb-4">
|
||||
<div class="card border-left-primary shadow-sm h-100 py-2">
|
||||
<div class="card-body">
|
||||
<div class="row no-gutters align-items-center">
|
||||
<div class="col mr-2">
|
||||
<div class="text-xs font-weight-bold text-primary text-uppercase mb-1"><?= __('average_rating') ?></div>
|
||||
<div class="h5 mb-0 font-weight-bold text-gray-800">
|
||||
<?= $avg_rating ?> <i class="bi bi-star-fill text-warning"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<i class="bi bi-star fa-2x text-gray-300" style="font-size: 2rem; color: #dddfeb;"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-xl-3 col-md-6 mb-4">
|
||||
<div class="card border-left-success shadow-sm h-100 py-2">
|
||||
<div class="card-body">
|
||||
<div class="row no-gutters align-items-center">
|
||||
<div class="col mr-2">
|
||||
<div class="text-xs font-weight-bold text-success text-uppercase mb-1"><?= __('total_ratings') ?></div>
|
||||
<div class="h5 mb-0 font-weight-bold text-gray-800"><?= number_format($total_ratings) ?></div>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<i class="bi bi-chat-left-text fa-2x text-gray-300" style="font-size: 2rem; color: #dddfeb;"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Ratings Table -->
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-header bg-white py-3">
|
||||
<h6 class="m-0 font-weight-bold text-primary"><?= __('ratings') ?></h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered table-hover w-100">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th><?= __('date') ?></th>
|
||||
<th><?= __('rating_type') ?></th>
|
||||
<th><?= __('rating') ?></th>
|
||||
<th><?= __('comment') ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (empty($ratings)): ?>
|
||||
<tr>
|
||||
<td colspan="4" class="text-center text-muted"><?= __('no_data_available') ?></td>
|
||||
</tr>
|
||||
<?php else: ?>
|
||||
<?php foreach ($ratings as $r): ?>
|
||||
<tr>
|
||||
<td><?= date('Y-m-d H:i', strtotime($r['created_at'])) ?></td>
|
||||
<td>
|
||||
<?php if ($r['rating_type'] === 'staff'): ?>
|
||||
<span class="badge bg-info text-dark"><?= __('staff') ?></span>
|
||||
<?php else: ?>
|
||||
<span class="badge bg-secondary"><?= __('service') ?></span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php for($i=1; $i<=5; $i++): ?>
|
||||
<i class="bi bi-star<?= $i <= $r['rating_value'] ? '-fill text-warning' : ' text-muted' ?>"></i>
|
||||
<?php endfor; ?>
|
||||
</td>
|
||||
<td><?= htmlspecialchars($r['comment']) ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<?php require_once __DIR__ . '/includes/footer.php'; ?>
|
||||
139
service_rating.php
Normal file
139
service_rating.php
Normal file
@ -0,0 +1,139 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/db/config.php';
|
||||
require_once __DIR__ . '/includes/lang.php';
|
||||
|
||||
$success = false;
|
||||
$error = '';
|
||||
|
||||
$branch_id_get = isset($_GET['branch_id']) ? (int)$_GET['branch_id'] : null;
|
||||
$info = null;
|
||||
|
||||
if ($branch_id_get) {
|
||||
$stmt = db()->prepare("SELECT b.id AS branch_id, b.name_en AS branch_name_en, b.name_ar AS branch_name_ar, c.id AS company_id, c.name_en AS comp_name_en, c.name_ar AS comp_name_ar, c.logo FROM branches b JOIN companies c ON b.company_id = c.id WHERE b.id = ?");
|
||||
$stmt->execute([$branch_id_get]);
|
||||
$info = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
if (empty($info)) {
|
||||
$stmt = db()->query("SELECT b.id AS branch_id, b.name_en AS branch_name_en, b.name_ar AS branch_name_ar, c.id AS company_id, c.name_en AS comp_name_en, c.name_ar AS comp_name_ar, c.logo FROM branches b JOIN companies c ON b.company_id = c.id LIMIT 1");
|
||||
$info = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
$branch_id = $info['branch_id'] ?? null;
|
||||
$company_id = $info['company_id'] ?? null;
|
||||
$company_name = $_SESSION['lang'] === 'ar' ? ($info['comp_name_ar'] ?? '') : ($info['comp_name_en'] ?? '');
|
||||
$branch_name = $_SESSION['lang'] === 'ar' ? ($info['branch_name_ar'] ?? '') : ($info['branch_name_en'] ?? '');
|
||||
$logo = $info['logo'] ?? null;
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$rating = (int)($_POST['rating'] ?? 0);
|
||||
$comment = $_POST['comment'] ?? '';
|
||||
|
||||
if ($rating < 1 || $rating > 5) {
|
||||
$error = __('provide_valid_rating');
|
||||
} else {
|
||||
$stmt = db()->prepare("INSERT INTO ratings (branch_id, company_id, rating_type, rating_value, comment) VALUES (?, ?, 'service', ?, ?)");
|
||||
if ($stmt->execute([$branch_id, $company_id, $rating, $comment])) {
|
||||
$success = true;
|
||||
} else {
|
||||
$error = __('error_saving_rating');
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="<?= $_SESSION['lang'] ?>" dir="<?= $_SESSION['lang'] === 'ar' ? 'rtl' : 'ltr' ?>">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title><?= __('service_rating') ?></title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css">
|
||||
<style>
|
||||
body { background-color: #f8f9fc; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; display: flex; flex-direction: column; min-height: 100vh; }
|
||||
.rating-card { max-width: 500px; margin: 40px auto; border-radius: 15px; border: none; box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15); padding: 30px; background: white; }
|
||||
.stars { display: flex; flex-direction: row-reverse; justify-content: center; margin-bottom: 20px; }
|
||||
.stars input { display: none; }
|
||||
.stars label { font-size: 2.5rem; color: #ddd; cursor: pointer; transition: color 0.2s; padding: 0 5px; }
|
||||
.stars label:hover, .stars label:hover ~ label, .stars input:checked ~ label { color: #f6c23e; }
|
||||
.btn-submit { border-radius: 30px; padding: 10px 30px; font-weight: 600; }
|
||||
.main-content { flex: 1; }
|
||||
.footer { background-color: white; border-top: 1px solid #eaecf4; padding: 1.5rem 0; color: #858796; text-align: center; }
|
||||
<?php if ($_SESSION['lang'] === 'ar'): ?>
|
||||
.stars { flex-direction: row; }
|
||||
.stars label:hover ~ label, .stars input:checked ~ label { color: #ddd; }
|
||||
.stars label:hover, .stars label:hover ~ label, .stars input:checked, .stars input:checked ~ label { color: #f6c23e !important; }
|
||||
<?php endif; ?>
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="main-content">
|
||||
<div class="container py-5">
|
||||
|
||||
<div class="text-end mb-3">
|
||||
<?php if ($_SESSION['lang'] === 'ar'): ?>
|
||||
<a href="?lang=en<?= isset($_GET['branch_id']) ? '&branch_id=' . (int)$_GET['branch_id'] : '' ?>" class="text-decoration-none btn btn-sm btn-outline-secondary">English</a>
|
||||
<?php else: ?>
|
||||
<a href="?lang=ar<?= isset($_GET['branch_id']) ? '&branch_id=' . (int)$_GET['branch_id'] : '' ?>" class="text-decoration-none btn btn-sm btn-outline-secondary">العربية</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="rating-card text-center">
|
||||
<?php if ($logo): ?>
|
||||
<img src="<?= htmlspecialchars($logo) ?>" alt="<?= htmlspecialchars($company_name) ?>" class="mb-3" style="max-height: 80px; max-width: 100%; object-fit: contain;">
|
||||
<?php endif; ?>
|
||||
<h4 class="mb-1 fw-bold"><?= htmlspecialchars($company_name) ?></h4>
|
||||
<?php if ($branch_name): ?>
|
||||
<p class="text-muted mb-4 small"><i class="bi bi-geo-alt-fill text-danger me-1"></i><?= htmlspecialchars($branch_name) ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<h2 class="mb-4 text-primary border-top pt-4"><?= __('service_rating') ?></h2>
|
||||
|
||||
<?php if ($success): ?>
|
||||
<div class="alert alert-success">
|
||||
<i class="bi bi-check-circle-fill"></i> <?= __('rating_submitted') ?>
|
||||
</div>
|
||||
<a href="service_rating.php<?= isset($_GET['branch_id']) ? '?branch_id=' . (int)$_GET['branch_id'] : '' ?>" class="btn btn-outline-primary mt-3"><?= __('submit_another') ?></a>
|
||||
<?php else: ?>
|
||||
|
||||
<?php if ($error): ?>
|
||||
<div class="alert alert-danger"><?= htmlspecialchars($error) ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<form method="POST">
|
||||
<p class="text-muted mb-2"><?= __('how_rate_service') ?></p>
|
||||
<div class="stars">
|
||||
<input type="radio" id="star5" name="rating" value="5" required />
|
||||
<label for="star5" title="5 stars"><i class="bi bi-star-fill"></i></label>
|
||||
<input type="radio" id="star4" name="rating" value="4" />
|
||||
<label for="star4" title="4 stars"><i class="bi bi-star-fill"></i></label>
|
||||
<input type="radio" id="star3" name="rating" value="3" />
|
||||
<label for="star3" title="3 stars"><i class="bi bi-star-fill"></i></label>
|
||||
<input type="radio" id="star2" name="rating" value="2" />
|
||||
<label for="star2" title="2 stars"><i class="bi bi-star-fill"></i></label>
|
||||
<input type="radio" id="star1" name="rating" value="1" />
|
||||
<label for="star1" title="1 star"><i class="bi bi-star-fill"></i></label>
|
||||
</div>
|
||||
|
||||
<div class="mb-4 text-start">
|
||||
<label for="comment" class="form-label"><?= __('comment') ?> (<?= __('optional') ?>)</label>
|
||||
<textarea class="form-control" id="comment" name="comment" rows="3" placeholder="<?= __('comment_placeholder') ?>"></textarea>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary btn-submit w-100"><?= __('submit_rating') ?></button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<span>© <?= date('Y') ?> <?= htmlspecialchars($company_name) ?>. <?= __('all_rights_reserved') ?></span>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
139
staff_rating.php
Normal file
139
staff_rating.php
Normal file
@ -0,0 +1,139 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/db/config.php';
|
||||
require_once __DIR__ . '/includes/lang.php';
|
||||
|
||||
$success = false;
|
||||
$error = '';
|
||||
|
||||
$branch_id_get = isset($_GET['branch_id']) ? (int)$_GET['branch_id'] : null;
|
||||
$info = null;
|
||||
|
||||
if ($branch_id_get) {
|
||||
$stmt = db()->prepare("SELECT b.id AS branch_id, b.name_en AS branch_name_en, b.name_ar AS branch_name_ar, c.id AS company_id, c.name_en AS comp_name_en, c.name_ar AS comp_name_ar, c.logo FROM branches b JOIN companies c ON b.company_id = c.id WHERE b.id = ?");
|
||||
$stmt->execute([$branch_id_get]);
|
||||
$info = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
if (empty($info)) {
|
||||
$stmt = db()->query("SELECT b.id AS branch_id, b.name_en AS branch_name_en, b.name_ar AS branch_name_ar, c.id AS company_id, c.name_en AS comp_name_en, c.name_ar AS comp_name_ar, c.logo FROM branches b JOIN companies c ON b.company_id = c.id LIMIT 1");
|
||||
$info = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
$branch_id = $info['branch_id'] ?? null;
|
||||
$company_id = $info['company_id'] ?? null;
|
||||
$company_name = $_SESSION['lang'] === 'ar' ? ($info['comp_name_ar'] ?? '') : ($info['comp_name_en'] ?? '');
|
||||
$branch_name = $_SESSION['lang'] === 'ar' ? ($info['branch_name_ar'] ?? '') : ($info['branch_name_en'] ?? '');
|
||||
$logo = $info['logo'] ?? null;
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$rating = (int)($_POST['rating'] ?? 0);
|
||||
$comment = $_POST['comment'] ?? '';
|
||||
|
||||
if ($rating < 1 || $rating > 5) {
|
||||
$error = __('provide_valid_rating');
|
||||
} else {
|
||||
$stmt = db()->prepare("INSERT INTO ratings (branch_id, company_id, rating_type, rating_value, comment) VALUES (?, ?, 'staff', ?, ?)");
|
||||
if ($stmt->execute([$branch_id, $company_id, $rating, $comment])) {
|
||||
$success = true;
|
||||
} else {
|
||||
$error = __('error_saving_rating');
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="<?= $_SESSION['lang'] ?>" dir="<?= $_SESSION['lang'] === 'ar' ? 'rtl' : 'ltr' ?>">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title><?= __('staff_rating') ?></title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css">
|
||||
<style>
|
||||
body { background-color: #f8f9fc; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; display: flex; flex-direction: column; min-height: 100vh; }
|
||||
.rating-card { max-width: 500px; margin: 40px auto; border-radius: 15px; border: none; box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15); padding: 30px; background: white; }
|
||||
.stars { display: flex; flex-direction: row-reverse; justify-content: center; margin-bottom: 20px; }
|
||||
.stars input { display: none; }
|
||||
.stars label { font-size: 2.5rem; color: #ddd; cursor: pointer; transition: color 0.2s; padding: 0 5px; }
|
||||
.stars label:hover, .stars label:hover ~ label, .stars input:checked ~ label { color: #f6c23e; }
|
||||
.btn-submit { border-radius: 30px; padding: 10px 30px; font-weight: 600; }
|
||||
.main-content { flex: 1; }
|
||||
.footer { background-color: white; border-top: 1px solid #eaecf4; padding: 1.5rem 0; color: #858796; text-align: center; }
|
||||
<?php if ($_SESSION['lang'] === 'ar'): ?>
|
||||
.stars { flex-direction: row; } /* RTL fix for stars order */
|
||||
.stars label:hover ~ label, .stars input:checked ~ label { color: #ddd; }
|
||||
.stars label:hover, .stars label:hover ~ label, .stars input:checked, .stars input:checked ~ label { color: #f6c23e !important; }
|
||||
<?php endif; ?>
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="main-content">
|
||||
<div class="container py-5">
|
||||
|
||||
<div class="text-end mb-3">
|
||||
<?php if ($_SESSION['lang'] === 'ar'): ?>
|
||||
<a href="?lang=en<?= isset($_GET['branch_id']) ? '&branch_id=' . (int)$_GET['branch_id'] : '' ?>" class="text-decoration-none btn btn-sm btn-outline-secondary">English</a>
|
||||
<?php else: ?>
|
||||
<a href="?lang=ar<?= isset($_GET['branch_id']) ? '&branch_id=' . (int)$_GET['branch_id'] : '' ?>" class="text-decoration-none btn btn-sm btn-outline-secondary">العربية</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="rating-card text-center">
|
||||
<?php if ($logo): ?>
|
||||
<img src="<?= htmlspecialchars($logo) ?>" alt="<?= htmlspecialchars($company_name) ?>" class="mb-3" style="max-height: 80px; max-width: 100%; object-fit: contain;">
|
||||
<?php endif; ?>
|
||||
<h4 class="mb-1 fw-bold"><?= htmlspecialchars($company_name) ?></h4>
|
||||
<?php if ($branch_name): ?>
|
||||
<p class="text-muted mb-4 small"><i class="bi bi-geo-alt-fill text-danger me-1"></i><?= htmlspecialchars($branch_name) ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<h2 class="mb-4 text-primary border-top pt-4"><?= __('staff_rating') ?></h2>
|
||||
|
||||
<?php if ($success): ?>
|
||||
<div class="alert alert-success">
|
||||
<i class="bi bi-check-circle-fill"></i> <?= __('rating_submitted') ?>
|
||||
</div>
|
||||
<a href="staff_rating.php<?= isset($_GET['branch_id']) ? '?branch_id=' . (int)$_GET['branch_id'] : '' ?>" class="btn btn-outline-primary mt-3"><?= __('submit_another') ?></a>
|
||||
<?php else: ?>
|
||||
|
||||
<?php if ($error): ?>
|
||||
<div class="alert alert-danger"><?= htmlspecialchars($error) ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<form method="POST">
|
||||
<p class="text-muted mb-2"><?= __('how_rate_staff') ?></p>
|
||||
<div class="stars">
|
||||
<input type="radio" id="star5" name="rating" value="5" required />
|
||||
<label for="star5" title="5 stars"><i class="bi bi-star-fill"></i></label>
|
||||
<input type="radio" id="star4" name="rating" value="4" />
|
||||
<label for="star4" title="4 stars"><i class="bi bi-star-fill"></i></label>
|
||||
<input type="radio" id="star3" name="rating" value="3" />
|
||||
<label for="star3" title="3 stars"><i class="bi bi-star-fill"></i></label>
|
||||
<input type="radio" id="star2" name="rating" value="2" />
|
||||
<label for="star2" title="2 stars"><i class="bi bi-star-fill"></i></label>
|
||||
<input type="radio" id="star1" name="rating" value="1" />
|
||||
<label for="star1" title="1 star"><i class="bi bi-star-fill"></i></label>
|
||||
</div>
|
||||
|
||||
<div class="mb-4 text-start">
|
||||
<label for="comment" class="form-label"><?= __('comment') ?> (<?= __('optional') ?>)</label>
|
||||
<textarea class="form-control" id="comment" name="comment" rows="3" placeholder="<?= __('comment_placeholder') ?>"></textarea>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary btn-submit w-100"><?= __('submit_rating') ?></button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<span>© <?= date('Y') ?> <?= htmlspecialchars($company_name) ?>. <?= __('all_rights_reserved') ?></span>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@ -28,7 +28,8 @@ $manageable_pages = [
|
||||
'profile.php' => 'user_profile',
|
||||
'company_profile.php' => 'company_profile',
|
||||
'order_details.php' => 'order_details',
|
||||
'receipt.php' => 'receipt'
|
||||
'receipt.php' => 'receipt',
|
||||
'ratings.php' => 'ratings'
|
||||
];
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action'])) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user