<?php $pageTitle='Danh mục dịch vụ - PET SPA'; $pageStyles=['owner.css']; $activeOwnerPage='service-categories'; $successMessage=$_SESSION['flash_success']??null; $errorMessage=$_SESSION['flash_error']??null; unset($_SESSION['flash_success'],$_SESSION['flash_error']); require BASE_PATH.'/app/views/layouts/header.php'; require BASE_PATH.'/app/views/layouts/navbar.php'; ?>
<main class="owner-area"><div class="container-fluid"><div class="row"><?php require BASE_PATH.'/app/views/layouts/owner-sidebar.php'; ?><section class="col-lg-9 col-xl-10 py-4"><h1 class="h3">Danh mục dịch vụ</h1><?php if($successMessage): ?><div class="alert alert-success"><?=htmlspecialchars($successMessage)?></div><?php endif; ?><?php if($errorMessage): ?><div class="alert alert-danger"><?=htmlspecialchars($errorMessage)?></div><?php endif; ?><form class="card card-body mb-4" method="post" action="<?=BASE_URL?>/?url=owner/service-category/store"><input type="hidden" name="_token" value="<?=htmlspecialchars($_SESSION['csrf_token']??'')?>"><div class="row g-2"><div class="col-md-4"><input class="form-control" name="name" maxlength="120" placeholder="Tên danh mục" required></div><div class="col-md-4"><input class="form-control" name="description" placeholder="Mô tả"></div><div class="col-md-2"><input class="form-control" type="number" name="sort_order" value="0"></div><div class="col-md-1 form-check pt-2"><input class="form-check-input" type="checkbox" name="is_active" checked></div><div class="col-md-1"><button class="btn btn-primary">Thêm</button></div></div></form><table class="table"><thead><tr><th>Tên</th><th>Dịch vụ</th><th>Thứ tự</th><th>Trạng thái</th><th></th></tr></thead><tbody><?php foreach($categories as $item): ?><tr><td><?=htmlspecialchars($item['name'])?></td><td><?=$item['service_count']?></td><td><?=$item['sort_order']?></td><td><?=$item['is_active']?'Hiện':'Ẩn'?></td><td><form class="d-inline" method="post" action="<?=BASE_URL?>/?url=owner/service-category/toggle"><input type="hidden" name="_token" value="<?=htmlspecialchars($_SESSION['csrf_token']??'')?>"><input type="hidden" name="category_id" value="<?=$item['id']?>"><button class="btn btn-sm btn-outline-secondary">Đổi trạng thái</button></form><details class="mt-2"><summary class="small">Sửa</summary><form class="row g-1 mt-1" method="post" action="<?=BASE_URL?>/?url=owner/service-category/update"><input type="hidden" name="_token" value="<?=htmlspecialchars($_SESSION['csrf_token']??'')?>"><input type="hidden" name="category_id" value="<?=$item['id']?>"><div class="col-12"><input class="form-control form-control-sm" name="name" maxlength="120" value="<?=htmlspecialchars($item['name'])?>" required></div><div class="col-12"><input class="form-control form-control-sm" name="description" value="<?=htmlspecialchars($item['description']??'')?>"></div><div class="col-6"><input class="form-control form-control-sm" type="number" name="sort_order" value="<?=$item['sort_order']?>"></div><div class="col-6 form-check pt-1"><input class="form-check-input" type="checkbox" name="is_active" <?=$item['is_active']?'checked':''?>><button class="btn btn-sm btn-primary">Lưu</button></div></form></details></td></tr><?php endforeach;?></tbody></table></section></div></div></main><?php require BASE_PATH.'/app/views/layouts/footer.php'; ?>
