AIPT/cms_admin/product_view.php
2024-10-29 03:42:53 +00:00

95 lines
5.2 KiB
PHP

<?php include('container/security.php');?>
<!DOCTYPE html>
<html lang="en" data-theme="light">
<head>
<!-- head links start -->
<?php include 'container/head_links.php';?>
<!-- head links start -->
</head>
<body>
<!-- side_bar start -->
<?php include 'container/side_bar.php' ?>
<!-- side_bar end -->
<main class="dashboard-main">
<!-- Header start -->
<?php include 'container/header.php' ?>
<div class="dashboard-main-body">
<div class="d-flex flex-wrap align-items-center justify-content-between gap-3 mb-24">
<h6 class="fw-semibold mb-0">AI Tool Products</h6>
<ul class="d-flex align-items-center gap-2">
<a href="product_add" class="btn btn-primary">+ Add Product</a>
</ul>
</div>
<div class="card basic-data-table">
<div class="card-header">
<h5 class="card-title mb-0">All Products List</h5>
</div>
<div class="card-body">
<table class="table bordered-table mb-0" id="dataTable" data-page-length='10'>
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Icon</th>
<th scope="col">Title</th>
<th scope="col">Category</th>
<th scope="col">Link</th>
<th scope="col">Description</th>
<th scope="col">Actions</th>
</tr>
</thead>
<tbody>
<?php
// Fetch products and categories
$result = mysqli_query($conn, "
SELECT p.id, p.title, p.icon, p.image, p.tracking_link, p.short_description, p.status, c.c_name as category_name
FROM products p
JOIN categories c ON p.category_id = c.id
");
$i = 1;
while ($row = mysqli_fetch_assoc($result)) {
$product_id = $row['id'];
$product_title = htmlspecialchars($row['title']);
$product_image = htmlspecialchars($row['icon']);
$tracking_link = htmlspecialchars($row['tracking_link']);
$short_description = htmlspecialchars($row['short_description']);
$status = htmlspecialchars($row['status']) === 'active' ? 'Active' : 'Inactive';
$status_class = $status === 'Active' ? 'bg-success-focus text-success-main' : 'bg-danger-focus text-danger-main';
echo "
<tr>
<td>
$i
</td>
<td><img src='/cms_admin/$product_image' alt='Product Image' class='img-thumbnail' style='width: 50px; height: auto;'></td>
<td>$product_title</td>
<td>" . htmlspecialchars($row['category_name']) . "</td>
<td><a href='$tracking_link' class='text-primary-600' target='_blank'>Link</a></td>
<td><textarea readonly class='form-control' rows='3'>$short_description</textarea></td>
<td>
<a href='product_edit.php?id=$product_id' class='w-32-px h-32-px bg-success-focus text-success-main rounded-circle d-inline-flex align-items-center justify-content-center'>
<iconify-icon icon='lucide:edit'></iconify-icon>
</a>
<a href='product_delete.php?id=$product_id' class='w-32-px h-32-px bg-danger-focus text-danger-main rounded-circle d-inline-flex align-items-center justify-content-center' onclick='return confirm(\"Are you sure you want to delete this product?\");'>
<iconify-icon icon='mingcute:delete-2-line'></iconify-icon>
</a>
</td>
</tr>";
$i++; }
mysqli_close($conn);
?>
</tbody>
</table>
</div>
</div>
</div>
<?php include 'container/footer.php' ?>
</main>
<!-- Footer Links Start -->
<?php include 'container/footer_links.php' ?>
<script>
let table = new DataTable('#dataTable');
</script>
</body>
</html>