<?php
include 'auth.php';
require_permission('settings_view');
include 'includes/header.php';
// Fetch all settings
$settings_result = $conn->query("SELECT * FROM settings");
$settings = [];
while($row = $settings_result->fetch_assoc()) {
$settings[$row['setting_key']] = $row['setting_value'];
}
?>
<h3 class="fs-4 mb-3">إعدادات الموقع العامة</h3>
<?php if(isset($_GET['success'])): ?>
<div class="alert alert-success">تم حفظ الإعدادات بنجاح.</div>
<?php endif; ?>
<div class="row">
<div class="col">
<div class="glass-card p-4">
<form action="settings_process.php" method="POST">
<div class="mb-3">
<label for="site_title" class="form-label">اسم الموقع</label>
<input type="text" class="form-control" id="site_title" name="site_title" value="<?= htmlspecialchars($settings['site_title'] ?? '') ?>">
</div>
<div class="mb-3">
<label for="site_logo" class="form-label">لوجو الموقع</label>
<input type="file" class="form-control" id="site_logo" name="site_logo" accept="image/*">
<?php if (!empty($settings['site_logo'])): ?>
<div class="mt-2">
<small>اللوجو الحالي:</small>
<img src="../uploads/<?= htmlspecialchars($settings['site_logo']) ?>" width="100" class="ms-2 rounded">
<input type="hidden" name="current_logo" value="<?= htmlspecialchars($settings['site_logo']) ?>">
</div>
<?php endif; ?>
</div>
<div class="mb-3">
<label for="logo_size" class="form-label">حجم اللوجو في الهيدر (بالبكسل PX)</label>
<input type="number" class="form-control" id="logo_size" name="logo_size" min="30" max="150" value="<?= htmlspecialchars($settings['logo_size'] ?? '70') ?>">
<div class="form-text text-muted">القيمة الافتراضية هي 70px. يوصى باختيار قيمة بين 30 و 150.</div>
</div>
<hr>
<h5 class="mb-3">معلومات التواصل</h5>
<div class="mb-3">
<label for="contact_email" class="form-label">البريد الإلكتروني للتواصل</label>
<input type="email" class="form-control" id="contact_email" name="contact_email" value="<?= htmlspecialchars($settings['contact_email'] ?? '') ?>">
</div>
<div class="mb-3">
<label for="contact_phone" class="form-label">رقم الهاتف للتواصل</label>
<input type="text" class="form-control" id="contact_phone" name="contact_phone" value="<?= htmlspecialchars($settings['contact_phone'] ?? '') ?>">
</div>
<div class="mb-3">
<label for="contact_address" class="form-label">العنوان الرئيسي</label>
<input type="text" class="form-control" id="contact_address" name="contact_address" value="<?= htmlspecialchars($settings['contact_address'] ?? '') ?>">
</div>
<div class="mb-3">
<label for="map_latitude" class="form-label">Latitude</label>
<input type="text" class="form-control" id="map_latitude" name="map_latitude" value="<?= htmlspecialchars($settings['map_latitude'] ?? '') ?>">
</div>
<div class="mb-3">
<label for="map_longitude" class="form-label">Longitude</label>
<input type="text" class="form-control" id="map_longitude" name="map_longitude" value="<?= htmlspecialchars($settings['map_longitude'] ?? '') ?>">
</div>
<hr>
<h5 class="mb-3">روابط التواصل الاجتماعي</h5>
<div class="mb-3">
<label for="facebook_url" class="form-label">رابط فيسبوك</label>
<input type="url" class="form-control" id="facebook_url" name="facebook_url" value="<?= htmlspecialchars($settings['facebook_url'] ?? '') ?>">
</div>
<div class="mb-3">
<label for="twitter_url" class="form-label">رابط تويتر</label>
<input type="url" class="form-control" id="twitter_url" name="twitter_url" value="<?= htmlspecialchars($settings['twitter_url'] ?? '') ?>">
</div>
<div class="mb-3">
<label for="instagram_url" class="form-label">رابط انستغرام</label>
<input type="url" class="form-control" id="instagram_url" name="instagram_url" value="<?= htmlspecialchars($settings['instagram_url'] ?? '') ?>">
</div>
<button type="submit" class="btn btn-success mt-3">حفظ الإعدادات</button>
</form>
</div>
</div>
</div>
<?php include 'includes/footer.php'; ?>