%PDF-1.4 %Óëéá 1 0 obj <> endobj 3 0 obj <> endobj 4 0 obj <
| Server IP : 212.252.79.165 / Your IP : 216.73.217.172 [ Web Server : Apache System : Linux 212-252-79-165.cprapid.com 5.15.0-153-generic #163-Ubuntu SMP Thu Aug 7 16:37:18 UTC 2025 x86_64 User : cehaburo ( 1001) PHP Version : 8.1.33 Disable Function : exec,passthru,shell_exec,system Domains : 48 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/cehaburo/www/admin/ |
Upload File : |
<?php
include 'lib/include.php';
// Fetch existing categories to allow selection of parent category
$category_list_query = $ceha->query("SELECT * FROM tbl_qr_category");
$categories = [];
while ($cat = $category_list_query->fetch_assoc()) {
$categories[] = $cat;
}
// Function to build the category tree
function buildCategoryTree(array $categories, $parent_id = 0) {
$branch = [];
foreach ($categories as $category) {
if ($category['parent_id'] == $parent_id) {
$children = buildCategoryTree($categories, $category['id']);
if ($children) {
$category['children'] = $children;
}
$branch[] = $category;
}
}
return $branch;
}
$category_tree = buildCategoryTree($categories);
include 'header.php';
?>
<div class="container">
<div class="row align-items-center mb-3">
<div class="col-6">
<div class="row">
<div class="col-6">
<h4 class="card-title">Yeni QR Kategori</h4>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 grid-margin stretch-card">
<div class="card">
<div class="card-body">
<h4 class="card-title">Kategori Oluştur</h4>
<form id="qrCategoryForm" action="dba/qr-category-create.php" method="post" class="forms-sample">
<div class="form-group">
<label for="categoryName">Kategori Adı</label>
<input type="text" class="form-control" id="categoryName" name="name" required>
</div>
<div class="form-group">
<label for="parentCategory">Üst Kategori</label>
<select class="form-control" id="parentCategory" name="parent_id">
<option value="">Seçiniz</option>
<?php
function renderCategoryOptions($categories, $level = 0, $current_parent_id = null, $current_category_id = null) {
foreach ($categories as $category) {
if ($category['id'] == $current_category_id) {
continue; // Do not show current category as an option
}
$selected = $category['id'] == $current_parent_id ? 'selected' : '';
echo '<option value="' . htmlspecialchars($category['id'], ENT_QUOTES, 'UTF-8') . '" ' . $selected . '>';
echo str_repeat(' ', $level * 4) . htmlspecialchars($category['name'], ENT_QUOTES, 'UTF-8');
echo '</option>';
if (isset($category['children'])) {
renderCategoryOptions($category['children'], $level + 1, $current_parent_id, $current_category_id);
}
}
}
renderCategoryOptions($category_tree, 0, $category['parent_id'], $category['id']);
?>
</select>
</div>
<button type="submit" class="btn btn-primary mr-2">Kaydet</button>
</form>
</div>
</div>
</div>
</div>
</div>
<?php include 'footer.php'; ?>