🖥️ Server: LiteSpeed
💻 System: Linux s20058.bom1.stableserver.net 5.14.0-611.55.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue May 19 15:19:29 EDT 2026 x86_64
👤 User: skhata (1324)
🐘 PHP: 8.4.20
🚫 Disabled: ✨ NONE
📄 team.php
📁 Path: /home/skhata/pimsnepal.com.np/admin/team.php
📊 Size: 4.53 KB
🔒 Perm: 0644
📝 MIME: text/x-php
<?php
require_once __DIR__ . '/../includes/functions.php';
requireAdmin();
require __DIR__ . '/includes/ui.php';
$pageTitle = 'Team Members';
if ($_SERVER['REQUEST_METHOD'] === 'POST' && csrfVerify($_POST['csrf_token'] ?? null)) {
$action = $_POST['action'] ?? '';
if ($action === 'save') {
$id = (int) ($_POST['id'] ?? 0);
$photoPath = handleUpload('photo', 'team');
$fields = [
trim($_POST['name'] ?? ''),
trim($_POST['role'] ?? ''),
trim($_POST['initials'] ?? ''),
(int) ($_POST['sort_order'] ?? 0),
isset($_POST['is_active']) ? 1 : 0,
];
if ($id > 0) {
if ($photoPath) {
db()->prepare('UPDATE team_members SET name=?,role=?,initials=?,sort_order=?,is_active=?,photo_path=? WHERE id=?')->execute([...$fields, $photoPath, $id]);
} else {
db()->prepare('UPDATE team_members SET name=?,role=?,initials=?,sort_order=?,is_active=? WHERE id=?')->execute([...$fields, $id]);
}
} else {
db()->prepare('INSERT INTO team_members (name,role,initials,sort_order,is_active,photo_path) VALUES (?,?,?,?,?,?)')->execute([...$fields, $photoPath]);
}
flash('success', 'Team member saved.');
} elseif ($action === 'delete') {
db()->prepare('DELETE FROM team_members WHERE id = ?')->execute([(int) ($_POST['id'] ?? 0)]);
flash('success', 'Team member deleted.');
}
redirect('team.php');
}
require __DIR__ . '/includes/admin-header.php';
adminFlashBox();
$items = db()->query('SELECT * FROM team_members ORDER BY sort_order ASC, id ASC')->fetchAll();
$editId = (int) ($_GET['edit'] ?? 0);
$editing = null;
foreach ($items as $i) { if ((int) $i['id'] === $editId) $editing = $i; }
?>
<div class="grid lg:grid-cols-3 gap-6">
<div class="lg:col-span-2 grid sm:grid-cols-2 gap-4">
<?php foreach ($items as $i): ?>
<div class="bg-white rounded-2xl border border-gray-100 p-4 flex items-center gap-3">
<?php if ($i['photo_path']): ?>
<img src="../<?= e($i['photo_path']) ?>" class="w-12 h-12 rounded-full object-cover shrink-0" />
<?php else: ?>
<div class="w-12 h-12 rounded-full bg-primary text-white flex items-center justify-center font-heading font-bold shrink-0"><?= e($i['initials']) ?></div>
<?php endif; ?>
<div class="flex-1 min-w-0">
<p class="text-sm font-semibold truncate"><?= e($i['name']) ?></p>
<p class="text-xs text-gray-500 truncate"><?= e($i['role']) ?></p>
</div>
<a href="?edit=<?= (int) $i['id'] ?>" class="text-primary text-xs font-semibold shrink-0">Edit</a>
<form method="post" onsubmit="return confirm('Delete?');" class="shrink-0">
<input type="hidden" name="csrf_token" value="<?= e(csrfToken()) ?>" />
<input type="hidden" name="action" value="delete" />
<input type="hidden" name="id" value="<?= (int) $i['id'] ?>" />
<button class="text-red-600 text-xs font-semibold">Del</button>
</form>
</div>
<?php endforeach; ?>
</div>
<div class="bg-white rounded-2xl border border-gray-100 p-6 h-fit">
<h2 class="font-heading font-semibold mb-4"><?= $editing ? 'Edit Team Member' : 'Add Team Member' ?></h2>
<form method="post" enctype="multipart/form-data">
<input type="hidden" name="csrf_token" value="<?= e(csrfToken()) ?>" />
<input type="hidden" name="action" value="save" />
<input type="hidden" name="id" value="<?= (int) ($editing['id'] ?? 0) ?>" />
<?php inputField('Name', 'name', $editing['name'] ?? '', 'text', true); ?>
<?php inputField('Role / Title', 'role', $editing['role'] ?? ''); ?>
<?php inputField('Initials (shown if no photo)', 'initials', $editing['initials'] ?? ''); ?>
<label class="block mb-4">
<span class="block text-sm font-medium text-gray-700 mb-1.5">Photo (optional)</span>
<input type="file" name="photo" accept="image/*" class="text-sm" />
</label>
<?php numberField('Sort Order', 'sort_order', $editing['sort_order'] ?? 0); ?>
<?php checkboxField('Active', 'is_active', $editing ? !empty($editing['is_active']) : true); ?>
<button class="btn-primary-brand bg-primary text-white px-5 py-2.5 rounded-lg font-semibold w-full"><?= $editing ? 'Update' : 'Add Team Member' ?></button>
<?php if ($editing): ?><a href="team.php" class="block text-center text-sm text-gray-500 mt-3">Cancel edit</a><?php endif; ?>
</form>
</div>
</div>
<?php require __DIR__ . '/includes/admin-footer.php'; ?>
✨ File Manager Magic ✨