141 lines
6.4 KiB
PHP
141 lines
6.4 KiB
PHP
<?php
|
|
// admin_profile.php
|
|
require_once __DIR__ . '/includes/app.php';
|
|
require_once __DIR__ . '/includes/auth.php';
|
|
|
|
require_permission('profile', 'view');
|
|
|
|
// Handle Profile Update
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['name'])) {
|
|
require_permission('profile', 'edit');
|
|
|
|
$name = $_POST['name'] ?? '';
|
|
$description = $_POST['description'] ?? '';
|
|
|
|
$logo_path = get_platform_profile()['logo_path'] ?? '';
|
|
$favicon_path = get_platform_profile()['favicon_path'] ?? '';
|
|
|
|
$upload_dir = __DIR__ . '/assets/images/uploads/';
|
|
if (!is_dir($upload_dir)) {
|
|
mkdir($upload_dir, 0777, true);
|
|
}
|
|
|
|
if (!empty($_FILES['logo']['tmp_name'])) {
|
|
$filename = 'logo_' . time() . '_' . basename($_FILES['logo']['name']);
|
|
$target = $upload_dir . $filename;
|
|
if (move_uploaded_file($_FILES['logo']['tmp_name'], $target)) {
|
|
$logo_path = 'assets/images/uploads/' . $filename;
|
|
}
|
|
}
|
|
|
|
if (!empty($_FILES['favicon']['tmp_name'])) {
|
|
$filename = 'favicon_' . time() . '_' . basename($_FILES['favicon']['name']);
|
|
$target = $upload_dir . $filename;
|
|
if (move_uploaded_file($_FILES['favicon']['tmp_name'], $target)) {
|
|
$favicon_path = 'assets/images/uploads/' . $filename;
|
|
}
|
|
}
|
|
|
|
$ctr_no = $_POST['ctr_no'] ?? '';
|
|
$telephone_no = $_POST['telephone_no'] ?? '';
|
|
$email_id = $_POST['email_id'] ?? '';
|
|
|
|
$terms = $_POST['terms'] ?? '';
|
|
$privacy_policy = $_POST['privacy_policy'] ?? '';
|
|
|
|
try {
|
|
$stmt = db()->prepare("UPDATE platform_profile SET name = :name, description = :description, logo_path = :logo, favicon_path = :favicon, ctr_no = :ctr_no, telephone_no = :telephone_no, email_id = :email_id, terms = :terms, privacy_policy = :privacy_policy WHERE id = 1");
|
|
$stmt->execute([
|
|
'name' => $name,
|
|
'description' => $description,
|
|
'logo' => $logo_path,
|
|
'favicon' => $favicon_path,
|
|
'ctr_no' => $ctr_no,
|
|
'telephone_no' => $telephone_no,
|
|
'email_id' => $email_id,
|
|
'terms' => $terms,
|
|
'privacy_policy' => $privacy_policy
|
|
]);
|
|
|
|
header('Location: ' . app_url('admin.php', ['page' => 'profile', 'saved' => 1]));
|
|
exit;
|
|
} catch (Exception $e) {
|
|
$error_message = "Error saving profile: " . $e->getMessage();
|
|
}
|
|
}
|
|
|
|
$prof = get_platform_profile();
|
|
?>
|
|
<div class="section-header mb-4">
|
|
<div>
|
|
<span class="eyebrow"><?= h(t('Settings', 'الإعدادات')) ?></span>
|
|
<h1 class="section-title mb-2"><?= h(t('Platform Profile', 'ملف المنصة')) ?></h1>
|
|
<p class="text-secondary mb-0"><?= h(t('Update your platforms name, description, logo, and favicon.', 'قم بتحديث اسم منصتك ووصفها وشعارها والأيقونة المفضلة.')) ?></p>
|
|
</div>
|
|
</div>
|
|
<?php if (!empty($_GET['saved'])): ?>
|
|
<div class="alert alert-success"><?= h(t('Profile updated successfully.', 'تم تحديث الملف بنجاح.')) ?></div>
|
|
<?php endif; ?>
|
|
<div class="panel-card" style="max-width: 600px;">
|
|
<form method="post" enctype="multipart/form-data">
|
|
<div class="mb-3">
|
|
<label class="form-label"><?= h(t('Platform Name', 'اسم المنصة')) ?></label>
|
|
<input type="text" name="name" class="form-control" value="<?= h($prof['name'] ?? '') ?>" required>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label class="form-label"><?= h(t('Description', 'الوصف')) ?></label>
|
|
<textarea name="description" class="form-control" rows="3"><?= h($prof['description'] ?? '') ?></textarea>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label class="form-label"><?= h(t('Logo', 'الشعار')) ?></label>
|
|
<?php if (!empty($prof['logo_path'])): ?>
|
|
<div class="mb-2">
|
|
<img src="<?= h(asset_url($prof['logo_path'])) ?>" alt="Logo" style="height: 60px; border: 1px solid var(--border); border-radius: 8px; padding: 4px; background: #fff;">
|
|
</div>
|
|
<?php endif; ?>
|
|
<input type="file" name="logo" class="form-control" accept="image/*">
|
|
</div>
|
|
<div class="mb-4">
|
|
<label class="form-label"><?= h(t('Favicon', 'الأيقونة المفضلة')) ?></label>
|
|
<?php if (!empty($prof['favicon_path'])): ?>
|
|
<div class="mb-2">
|
|
<img src="<?= h(asset_url($prof['favicon_path'])) ?>" alt="Favicon" style="height: 32px; border: 1px solid var(--border); border-radius: 4px; padding: 2px; background: #fff;">
|
|
</div>
|
|
<?php endif; ?>
|
|
<input type="file" name="favicon" class="form-control" accept="image/x-icon,image/png,image/jpeg,image/svg+xml">
|
|
</div>
|
|
|
|
<h5 class="mb-3 mt-4"><?= h(t('Contact Information', 'معلومات الاتصال')) ?></h5>
|
|
<div class="row g-3 mb-4">
|
|
<div class="col-md-6">
|
|
<label class="form-label"><?= h(t('Email', 'البريد الإلكتروني')) ?></label>
|
|
<input type="email" name="email_id" class="form-control" value="<?= h($prof['email_id'] ?? '') ?>">
|
|
</div>
|
|
<div class="col-md-6">
|
|
<label class="form-label"><?= h(t('Phone Number', 'رقم الهاتف')) ?></label>
|
|
<input type="text" name="telephone_no" class="form-control" value="<?= h($prof['telephone_no'] ?? '') ?>">
|
|
</div>
|
|
<div class="col-md-12">
|
|
<label class="form-label"><?= h(t('Commercial Registration No.', 'رقم السجل التجاري')) ?></label>
|
|
<input type="text" name="ctr_no" class="form-control" value="<?= h($prof['ctr_no'] ?? '') ?>">
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<h5 class="mb-3 mt-4"><?= h(t('Terms of Conditions', 'الشروط والأحكام'))?></h5>
|
|
<div class="mb-3">
|
|
<label class="form-label"><?= h(t('Terms of Conditions', 'الشروط والأحكام'))?></label>
|
|
<textarea name="terms" class="form-control" rows="5"><?= h($prof['terms'] ?? '')?></textarea>
|
|
</div>
|
|
<div class="mb-4">
|
|
<label class="form-label"><?= h(t('Privacy Policy', 'سياسة الخصوصية'))?></label>
|
|
<textarea name="privacy_policy" class="form-control" rows="5"><?= h($prof['privacy_policy'] ?? '')?></textarea>
|
|
</div>
|
|
|
|
<button type="submit" class="btn btn-primary" style="background-color: var(--accent); border-color: var(--accent);">
|
|
|
|
<?= h(t('Save Changes', 'حفظ التغييرات')) ?>
|
|
</button>
|
|
</form>
|
|
</div>
|