| Server IP : 3.111.61.48 / Your IP : 216.73.216.67 Web Server : Apache System : Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64 User : ubuntu ( 1000) PHP Version : 8.2.31 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/vhost/book.gyaniguru.org/admin/ |
Upload File : |
<?php
require_once __DIR__ . '/../includes/db.php';
if (isset($_GET['delete'])) {
$id = (int)$_GET['delete'];
$conn->query("DELETE FROM photos WHERE id = $id");
header("Location: photos.php?msg=Photo deleted successfully");
exit();
}
include 'includes/header.php';
$sort = $_GET['sort'] ?? 'newest';
$status_filter = $_GET['status'] ?? '';
$sql = "SELECT * FROM photos WHERE 1=1";
$params = [];
if ($status_filter === 'featured') {
$sql .= " AND is_featured = 1";
} elseif ($status_filter === 'new') {
$sql .= " AND is_new = 1";
}
switch ($sort) {
case 'price_low': $sql .= " ORDER BY price ASC"; break;
case 'price_high': $sql .= " ORDER BY price DESC"; break;
case 'title_az': $sql .= " ORDER BY title ASC"; break;
case 'title_za': $sql .= " ORDER BY title DESC"; break;
default: $sql .= " ORDER BY created_at DESC";
}
$photos = get_all($sql, $params);
?>
<div class="d-flex flex-wrap justify-content-between align-items-center mb-4 gap-3">
<div class="d-flex flex-wrap align-items-center gap-2">
<div class="search-wrap" style="width: 220px;">
<div class="input-group">
<span class="input-group-text bg-transparent border-end-0" style="border-color: rgba(212,175,55,0.2);"><i class="bi bi-search text-muted"></i></span>
<input type="text" id="photoSearch" onkeyup="filterTable('photoSearch', 'photosTable')" class="form-control bg-transparent border-start-0" style="border-color: rgba(212,175,55,0.2); color: var(--text-dark)" placeholder="Search photos...">
</div>
</div>
<select class="form-select form-select-sm" style="width:auto; border-color: rgba(212,175,55,0.2); background:var(--warm-white); color:var(--text-dark);" onchange="window.location.href='photos.php?<?php echo http_build_query(array_merge($_GET, ['status' => ''])); ?>'.slice(0,-1) + this.value">
<option value="">All Status</option>
<option value="featured" <?php echo $status_filter === 'featured' ? 'selected' : ''; ?>>Featured</option>
<option value="new" <?php echo $status_filter === 'new' ? 'selected' : ''; ?>>New</option>
</select>
<select class="form-select form-select-sm" style="width:auto; border-color: rgba(212,175,55,0.2); background:var(--warm-white); color:var(--text-dark);" onchange="window.location.href='photos.php?<?php echo http_build_query(array_merge($_GET, ['sort' => ''])); ?>'.slice(0,-1) + this.value">
<option value="newest" <?php echo $sort == 'newest' ? 'selected' : ''; ?>>Newest First</option>
<option value="price_low" <?php echo $sort == 'price_low' ? 'selected' : ''; ?>>Price: Low-High</option>
<option value="price_high" <?php echo $sort == 'price_high' ? 'selected' : ''; ?>>Price: High-Low</option>
<option value="title_az" <?php echo $sort == 'title_az' ? 'selected' : ''; ?>>Title: A-Z</option>
<option value="title_za" <?php echo $sort == 'title_za' ? 'selected' : ''; ?>>Title: Z-A</option>
</select>
<?php if($status_filter || $sort !== 'newest'): ?>
<a href="photos.php" class="btn btn-sm btn-outline-secondary">Reset</a>
<?php endif; ?>
</div>
<a href="photo-add.php" class="btn btn-saffron px-4">
<i class="bi bi-plus-lg me-2"></i> Add New Guru Photo
</a>
</div>
<?php if(isset($_GET['msg'])): ?>
<div class="alert alert-success py-2 mb-4" style="font-size: 0.9rem;">
<i class="bi bi-check-circle me-2"></i> <?php echo $_GET['msg']; ?>
</div>
<?php endif; ?>
<div class="admin-card">
<div class="table-responsive">
<table class="table table-custom" id="photosTable">
<thead>
<tr>
<th>Photo</th>
<th>Pricing</th>
<th>Frame</th>
<th>Print</th>
<th>Stock</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php foreach($photos as $photo): ?>
<tr>
<td>
<div class="d-flex align-items-center gap-3">
<img src="../<?php echo $photo['image']; ?>" alt="" style="width:60px; height:45px; object-fit:cover; border-radius:6px; box-shadow: 0 4px 10px rgba(0,0,0,0.1);" onerror="this.src='../images/placeholder.png'">
<div>
<div style="font-weight:700; color: var(--maroon);"><?php echo $photo['title']; ?></div>
</div>
</div>
</td>
<td>
<div style="font-weight:700; color: var(--gerua-deep)">₹<?php echo $photo['price']; ?></div>
<?php if($photo['original_price'] > $photo['price']): ?>
<del class="text-muted small">₹<?php echo $photo['original_price']; ?></del>
<?php endif; ?>
</td>
<td style="font-size: 0.8rem">
<?php echo $photo['width'] ?: '-'; ?>"x<?php echo $photo['height'] ?: '-'; ?>"<br>
<small class="text-muted"><?php echo $photo['frame_type'] ?: ''; ?> <?php echo $photo['frame_color'] ?: ''; ?></small><br>
<small class="text-muted"><?php echo $photo['orientation'] ?: ''; ?></small>
</td>
<td style="font-size: 0.8rem">
<span class="badge py-1 px-2" style="background: var(--cream); color: var(--text-dark);"><?php echo $photo['print_type'] ?: '-'; ?></span>
<?php if($photo['weight']): ?><br><small class="text-muted"><?php echo $photo['weight']; ?>g</small><?php endif; ?>
</td>
<td>
<span class="badge py-2 px-3" style="background: <?php echo $photo['stock'] > 0 ? '#f0fff4' : '#fff5f5'; ?>; color: <?php echo $photo['stock'] > 0 ? '#2f855a' : '#e53e3e'; ?>;"><?php echo $photo['stock'] > 0 ? $photo['stock'] . ' in stock' : 'Out of Stock'; ?></span>
</td>
<td>
<?php if($photo['is_featured']): ?>
<span class="badge bg-warning text-dark" style="font-size:0.65rem">FEATURED</span>
<?php endif; ?>
<?php if($photo['is_new']): ?>
<span class="badge bg-info text-dark" style="font-size:0.65rem">NEW</span>
<?php endif; ?>
</td>
<td>
<div class="d-flex gap-2">
<a href="photo-edit.php?id=<?php echo $photo['id']; ?>" class="btn-action bg-info bg-opacity-10 text-info" title="Edit">
<i class="bi bi-pencil-square"></i>
</a>
<a href="photos.php?delete=<?php echo $photo['id']; ?>" class="btn-action bg-danger bg-opacity-10 text-danger" title="Delete" onclick="return confirm('Are you sure you want to delete this photo?')">
<i class="bi bi-trash"></i>
</a>
</div>
</td>
</tr>
<?php endforeach; if(empty($photos)) echo '<tr><td colspan="6" class="text-center py-5">No photos found in database.</td></tr>'; ?>
</tbody>
</table>
</div>
</div>
<?php include 'includes/footer.php'; ?>