<?php $pageTitle=($isNew?'Thêm':'Sửa').' người dùng - PET SPA'; $activeAdminPage='users'; require BASE_PATH.'/app/views/layouts/header.php'; require BASE_PATH.'/app/views/layouts/navbar.php'; ?>
<main class="admin-area"><div class="container-fluid"><div class="row g-4"><div class="col-lg-3 col-xl-2"><?php require BASE_PATH.'/app/views/layouts/admin-sidebar.php'; ?></div><section class="col-lg-9 col-xl-10"><h1 class="h3 mb-3"><?= $isNew?'Thêm người dùng':'Sửa người dùng' ?></h1><form method="post" action="<?=BASE_URL?>/?url=admin/user/save" class="card card-body"><input type="hidden" name="_token" value="<?=htmlspecialchars($_SESSION['csrf_token'])?>"><?php if(!$isNew):?><input type="hidden" name="user_id" value="<?= (int)$user['id'] ?>"><?php endif;?><div class="row g-3"><div class="col-md-6"><label class="form-label">Họ tên</label><input class="form-control" name="full_name" value="<?=htmlspecialchars($user['full_name'])?>" required></div><div class="col-md-6"><label class="form-label">Số điện thoại</label><input class="form-control" name="phone" value="<?=htmlspecialchars($user['phone'])?>" required></div><div class="col-md-6"><label class="form-label">Email</label><input type="email" class="form-control" name="email" value="<?=htmlspecialchars($user['email']??'')?>"></div><div class="col-md-6"><label class="form-label"><?= $isNew?'Mật khẩu':'Mật khẩu mới (nếu đổi)' ?></label><input type="password" class="form-control" name="password" <?= $isNew?'required minlength="8"':'' ?>></div><div class="col-md-6"><label class="form-label">Vai trò</label><select class="form-select" name="role"><?php foreach(['customer'=>'Customer','owner'=>'Owner'] as $key=>$label):?><option value="<?=$key?>" <?=$user['role']===$key?'selected':''?>><?=$label?></option><?php endforeach;?></select></div><div class="col-md-6"><label class="form-label">Trạng thái</label><select class="form-select" name="status"><option value="active" <?=$user['status']==='active'?'selected':''?>>Hoạt động</option><option value="locked" <?=$user['status']==='locked'?'selected':''?>>Đã khóa</option></select></div><div class="col-12"><button class="btn btn-primary">Lưu người dùng</button><a class="btn btn-link" href="<?=BASE_URL?>/?url=admin/users">Hủy</a></div></div></form></section></div></div></main><?php require BASE_PATH.'/app/views/layouts/footer.php'; ?>
