|
Server : LiteSpeed System : Linux quebec.us.hostns.io 5.14.0-687.42.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Aug 27 11:55:12 EDT 2026 x86_64 User : gazetufm ( 1431) PHP Version : 8.1.35 Disable Function : NONE Directory : /home2/gazetufm/drsupernova.com/locations/ | |
|
Path: //home2/gazetufm/drsupernova.com/locations/admin.php
Size: 17.23 KB
Permissions: 0644
<?php
session_start();
if (!isset($_SESSION['admin_logged_in']) || $_SESSION['admin_logged_in'] !== true) {
header("Location: login.php");
exit();
}
error_reporting(E_ALL);
ini_set('display_errors', 1);
include 'config.php';
if (isset($_POST['id']) && isset($_POST['status'])) {
$id = intval($_POST['id']);
$status = $_POST['status'];
$stmt = $conn->prepare("UPDATE Lokacionet SET Statusi = ? WHERE ID = ?");
$stmt->bind_param("si", $status, $id);
if ($stmt->execute()) {
echo "success";
} else {
echo "error";
}
}
?>
<!DOCTYPE html>
<html lang="sq">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin Dashboard | Dr. Supernova Location Finder</title>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&display=swap" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.datatables.net/1.13.6/css/dataTables.bootstrap5.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.0/font/bootstrap-icons.css">
<style>
:root {
--primary: #4361ee;
--secondary: #3f37c9;
--success: #4cc9f0;
--bg: #f8f9fd;
--card-shadow: 0 10px 30px rgba(0, 0, 0, 0.04);
}
body {
background-color: var(--bg);
font-family: 'Inter', sans-serif;
color: #2b2d42;
}
/* Modern Header */
.admin-navbar {
background: rgba(255, 255, 255, 0.8);
backdrop-filter: blur(10px);
border-bottom: 1px solid rgba(0,0,0,0.05);
padding: 0.8rem 2rem;
position: sticky;
top: 0;
z-index: 1000;
}
.navbar-brand {
font-weight: 700;
color: var(--primary) !important;
letter-spacing: -0.5px;
}
/* Stats Cards */
.card-stats {
background: #fff;
border: none;
border-radius: 20px;
box-shadow: var(--card-shadow);
transition: transform 0.3s ease;
}
.card-stats:hover {
transform: translateY(-5px);
}
.icon-shape {
width: 48px;
height: 48px;
background: rgba(67, 97, 238, 0.1);
color: var(--primary);
border-radius: 12px;
display: flex;
align-items: center;
justify-content: center;
font-size: 1.5rem;
}
/* Table Design */
.table-box {
background: #fff;
border-radius: 24px;
padding: 30px;
box-shadow: var(--card-shadow);
border: 1px solid rgba(0,0,0,0.02);
}
.table thead th {
background-color: #f8f9fa;
border-bottom: none;
text-transform: uppercase;
font-size: 0.75rem;
letter-spacing: 1px;
font-weight: 700;
color: #8d99ae;
padding: 15px;
}
.table tbody td {
padding: 18px 15px;
border-bottom: 1px solid #f1f3f9;
}
.status-badge {
border-radius: 8px;
padding: 6px 12px;
font-size: 0.8rem;
font-weight: 600;
background: rgba(76, 201, 240, 0.1);
color: var(--success);
}
.btn-action {
width: 35px;
height: 35px;
border-radius: 10px;
display: inline-flex;
align-items: center;
justify-content: center;
transition: all 0.2s;
}
/* Customizing DataTable */
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
background: var(--primary) !important;
border-color: var(--primary) !important;
color: white !important;
border-radius: 8px;
}
</style>
</head>
<body>
<nav class="navbar navbar-expand-lg admin-navbar shadow-sm">
<div class="container-fluid">
<a class="navbar-brand d-flex align-items-center" href="admin.php">
<i class="bi bi-geo-fill me-2"></i> DR. SUPERNOVA LOCATION FINDER <span class="badge bg-primary-subtle text-primary ms-2 fw-normal" style="font-size: 10px;">PRO</span>
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#adminNav">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="adminNav">
<ul class="navbar-nav ms-auto align-items-center">
<li class="nav-item">
<a href="index.php" class="nav-link text-dark fw-semibold me-3">
<i class="bi bi-plus-circle me-1"></i> Add Property
</a>
</li>
<li class="nav-item">
<a href="admin.php" class="nav-link text-primary fw-bold me-3">Proposals</a>
</li>
<li class="nav-item">
<a href="agencies.php" class="nav-link text-dark fw-semibold me-3">Agencies</a>
</li>
<li class="nav-item">
<div class="vr d-none d-lg-block h-100 mx-2 text-gray-300"></div>
</li>
<li class="nav-item">
<a href="logout.php" class="btn btn-outline-danger btn-sm border-0 fw-bold px-3">
<i class="bi bi-box-arrow-right me-1"></i> Sign Out
</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="container py-5">
<div class="mb-5">
<h2 class="fw-bold m-0">Dashboard Overview</h2>
<p class="text-muted small">Welcome back! Manage your listed locations and partner agencies.</p>
</div>
<div class="row g-4 mb-5">
<?php
$countL = $conn->query("SELECT COUNT(*) as total FROM Lokacionet")->fetch_assoc()['total'];
$countA = $conn->query("SELECT COUNT(*) as total FROM Agjencite")->fetch_assoc()['total'];
?>
<div class="col-md-4">
<a href="admin.php" class="text-decoration-none text-reset">
<div class="card card-stats p-4">
<div class="d-flex align-items-center">
<div class="icon-shape me-3">
<i class="bi bi-building"></i>
</div>
<div>
<p class="text-muted mb-0 small fw-bold text-uppercase">Total Proposals</p>
<h3 class="fw-bold mb-0"><?php echo $countL; ?></h3>
</div>
</div>
</div>
</a>
</div>
<div class="col-md-4">
<a href="agencies.php" class="text-decoration-none text-reset">
<div class="card card-stats p-4">
<div class="d-flex align-items-center text-success">
<div class="icon-shape me-3" style="background: rgba(25, 135, 84, 0.1); color: #198754;">
<i class="bi bi-people"></i>
</div>
<div>
<p class="text-muted mb-0 small fw-bold text-uppercase">Partner Agencies</p>
<h3 class="fw-bold mb-0 text-dark"><?php echo $countA; ?></h3>
</div>
</div>
</div>
</a>
</div>
</div>
<div class="table-box">
<div class="table-responsive">
<table id="dataTable" class="table align-middle">
<thead>
<tr>
<th>Agency & Contact</th>
<th>Location Details</th>
<th>Surface</th>
<th>Price</th>
<th>Status</th>
<th class="text-center">Action</th>
</tr>
</thead>
<tbody>
<?php
$sql = "SELECT L.*, A.EmriBiznesit, A.Tel, A.AgjentiKontakt, A.Email
FROM Lokacionet L JOIN Agjencite A ON L.AgjenciaID = A.ID ORDER BY L.ID DESC";
$result = $conn->query($sql);
while($row = $result->fetch_assoc()):
?>
<tr class="location-row" style="cursor: pointer;"
data-id="<?php echo $row['ID']; ?>"
data-status="<?php echo $row['Statusi']; ?>"
data-adresa="<?php echo htmlspecialchars($row['Adresa']); ?>"
data-pershkrimi="<?php echo htmlspecialchars($row['Pershkrimi']); ?>"
data-siperfaqja="<?php echo $row['Siperfaqja']; ?> ㎡"
data-kati="<?php echo htmlspecialchars($row['Kati']); ?>"
data-parkimi="<?php echo htmlspecialchars($row['Parkimi']); ?>"
data-vizibiliteti="<?php echo htmlspecialchars($row['Vizibiliteti']); ?>"
data-aksesi="<?php echo htmlspecialchars($row['Aksesi']); ?>"
data-infra-e="<?php echo htmlspecialchars($row['InfraEnergji']); ?>"
data-infra-t="<?php echo htmlspecialchars($row['Infrastruktura']); ?>"
data-qira="<?php echo number_format($row['CmimiQira'], 0); ?> €"
data-data="<?php echo htmlspecialchars($row['DataLirimit']); ?>"
data-agjencia="<?php echo htmlspecialchars($row['EmriBiznesit']); ?>"
data-agjenti="<?php echo htmlspecialchars($row['AgjentiKontakt']); ?>"
data-tel="<?php echo htmlspecialchars($row['Tel']); ?>"
data-foto="<?php echo htmlspecialchars($row['FotoLink']); ?>"
data-email="<?php echo htmlspecialchars($row['Email']); ?>"
data-maps="<?php echo $row['MapsLink']; ?>">
<td>
<div class="fw-bold"><?php echo $row['EmriBiznesit']; ?></div>
<div class="text-muted small"><i class="bi bi-telephone me-1"></i><?php echo $row['Tel']; ?></div>
</td>
<td>
<div class="small fw-semibold text-truncate" style="max-width: 200px;">
<i class="bi bi-geo-alt-fill text-danger me-1"></i><?php echo $row['Adresa']; ?>
</div>
<span class="text-primary x-small" style="font-size: 11px;">Click for Details</span>
</td>
<td>
<span class="badge bg-light text-dark border fw-medium px-2 py-2">
<?php echo $row['Siperfaqja']; ?> ㎡
</span>
</td>
<td>
<div class="fw-bold text-primary"><?php echo number_format($row['CmimiQira'], 0); ?> €</div>
</td>
<td>
<span class="status-badge">
<i class="bi bi-dot me-1"></i><?php echo $row['Statusi']; ?>
</span>
</td>
<td class="text-center" onclick="event.stopPropagation();">
<a href="<?php echo $row['FotoLink']; ?>" target="_blank" class="btn btn-light btn-action" title="View Files">
<i class="bi bi-folder-symlink text-primary"></i>
</a>
</td>
</tr>
<?php endwhile; ?>
</tbody>
</table>
</div>
</div>
</div>
<div class="modal fade" id="locModal" tabindex="-1" aria-hidden="true">
<div class="modal-dialog modal-lg modal-dialog-centered">
<div class="modal-content border-0 shadow-lg" style="border-radius: 20px;">
<div class="modal-header border-0 pb-0">
<h5 class="fw-bold"><i class="bi bi-building-check text-primary me-2"></i>Location Details</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body p-4">
<div class="row g-4">
<div class="col-md-7">
<label class="text-muted small fw-bold text-uppercase">Address</label>
<p class="fw-bold fs-5 mb-3" id="view-adresa"></p>
<label class="text-muted small fw-bold text-uppercase">Description</label>
<p id="view-pershkrimi" class="mb-3 text-secondary"></p>
<div class="row">
<div class="col-6">
<label class="text-muted small fw-bold text-uppercase">Area</label>
<p id="view-sip" class="fw-semibold"></p>
</div>
<div class="col-6">
<label class="text-muted small fw-bold text-uppercase">Floor</label>
<p id="view-kati" class="fw-semibold"></p>
</div>
</div>
<div class="row">
<label class="text-muted small fw-bold text-uppercase">Photos/Videos</label>
<a href="#" id="view-foto-link" target="_blank" class="btn btn-light border d-inline-flex align-items-center px-3" title="View Files">
<i class="bi bi-folder-symlink text-primary me-2"></i> View Files
</a>
</div>
</div>
<div class="col-md-5 bg-light rounded-4 p-3">
<hr>
<div class="mb-3">
<label class="text-muted small fw-bold text-uppercase d-block mb-2">Update Status</label>
<select id="update-status-select" class="form-select border-0 shadow-sm" style="border-radius: 10px;">
<option value="I ri">New</option>
<option value="Ne shqyrtim">Under review</option>
<option value="I pranuar">Accepted</option>
<option value="I refuzuar">Rejected</option>
</select>
</div>
<label class="text-muted small fw-bold text-uppercase">Technical Information</label>
<ul class="list-unstyled mt-2">
<li class="mb-2 small"><strong>Visibility:</strong> <span id="view-viz"></span></li>
<li class="mb-2 small"><strong>Access:</strong> <span id="view-aks"></span></li>
<li class="mb-2 small"><strong>Parking:</strong> <span id="view-park"></span></li>
<li class="mb-2 small"><strong>Electricity:</strong> <span id="view-infra-e"></span></li>
<li class="mb-2 small"><strong>Infrastructure:</strong> <span id="view-infra-t"></span></li>
</ul>
<hr>
<div class="text-center">
<label class="text-muted small fw-bold text-uppercase d-block mb-1">Monthly Rent</label>
<h4 class="text-primary fw-bold" id="view-qira"></h4>
</div>
</div>
</div>
</div>
<div class="modal-footer border-0">
<div class="me-auto small text-muted">
<i class="bi bi-person-badge me-1"></i> <span id="view-agj"></span>
</div>
<a href="#" id="view-maps" target="_blank" class="btn btn-primary rounded-pill px-4">Open in Google Maps <i class="bi bi-geo-alt ms-1"></i></a>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.7.0.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.13.6/js/dataTables.bootstrap5.min.js"></script>
<script>
$(document).ready(function() {
let currentLocId = null; // Track which ID we are editing
$('.location-row').on('click', function() {
const d = $(this).data();
currentLocId = d.id; // Store ID
$('#view-adresa').text(d.adresa);
$('#view-pershkrimi').text(d.pershkrimi || 'Nuk ka p�rshkrim t� shtuar.');
$('#view-sip').text(d.siperfaqja);
$('#view-kati').text(d.kati);
$('#view-park').text(d.parkimi);
$('#view-viz').text(d.vizibiliteti);
$('#view-aks').text(d.aksesi);
$('#view-infra-e').text(d.infraE);
$('#view-infra-t').text(d.infraT);
$('#view-qira').text(d.qira);
// Set the dropdown to current status
$('#update-status-select').val(d.status);
$('#view-foto-link').attr('href', d.foto);
$('#view-agj').text(d.agjencia + " (" + d.agjenti + " " + d.tel + ")");
$('#view-maps').attr('href', d.maps);
$('#locModal').modal('show');
});
// Handle Status Change
$('#update-status-select').on('change', function() {
const newStatus = $(this).val();
$.ajax({
url: 'update_status.php',
type: 'POST',
data: { id: currentLocId, status: newStatus },
success: function(response) {
if(response === "success") {
// Update the badge in the table without reloading
$(`tr[data-id="${currentLocId}"]`).find('.status-badge').html('<i class="bi bi-dot me-1"></i>' + newStatus);
// Update data attribute for next click
$(`tr[data-id="${currentLocId}"]`).data('status', newStatus);
alert('Status updated successfully!');
} else {
alert('Error updating status.');
}
}
});
});
});
</script>
</body>
</html>