<?php
include 'includes/header.php';
if (!has_permission('themes_view')) { // Assuming 'themes_view' is the permission to manage themes
echo "<div class='alert alert-danger'>ليس لديك الصلاحية لعرض هذه الصفحة.</div>";
include 'includes/footer.php';
exit;
}
$theme = ['id' => '', 'name' => '', 'css_file' => ''];
if (isset($_GET['id'])) {
$stmt = $conn->prepare("SELECT * FROM `themes` WHERE `id` = ?");
$stmt->bind_param('i', $_GET['id']);
$stmt->execute();
$result = $stmt->get_result();
$theme = $result->fetch_assoc();
}
?>
<div class="container-fluid">
<h1 class="mt-4"><?php echo isset($theme['id']) && $theme['id'] ? 'تعديل' : 'إضافة'; ?> ثيم</h1>
<form action="theme_process.php" method="post">
<input type="hidden" name="id" value="<?php echo $theme['id']; ?>">
<div class="mb-3">
<label for="name" class="form-label">اسم الثيم</label>
<input type="text" class="form-control" id="name" name="name" value="<?php echo htmlspecialchars($theme['name']); ?>" required>
</div>
<div class="mb-3">
<label for="css_file" class="form-label">ملف الـ CSS</label>
<input type="text" class="form-control" id="css_file" name="css_file" value="<?php echo htmlspecialchars($theme['css_file']); ?>" required>
</div>
<button type="submit" class="btn btn-primary">حفظ</button>
</form>
</div>
<?php include 'includes/footer.php'; ?>