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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Elite Visuals – Admin Panel</title>
|
| 7 |
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
|
| 8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 9 |
+
<script src="https://www.gstatic.com/firebasejs/9.22.1/firebase-app-compat.js"></script>
|
| 10 |
+
<script src="https://www.gstatic.com/firebasejs/9.22.1/firebase-database-compat.js"></script>
|
| 11 |
+
<style>
|
| 12 |
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
| 13 |
+
body { background: linear-gradient(135deg, #0a0a0f 0%, #12121a 100%); font-family: 'Inter', sans-serif; min-height: 100vh; padding: 30px; }
|
| 14 |
+
.container { max-width: 1600px; margin: 0 auto; }
|
| 15 |
+
h1 { color: white; margin-bottom: 10px; display: flex; align-items: center; gap: 15px; }
|
| 16 |
+
h1 i { color: #25D366; }
|
| 17 |
+
.subtitle { color: #8e8e9e; margin-bottom: 30px; }
|
| 18 |
+
.tabs { display: flex; gap: 10px; margin-bottom: 20px; }
|
| 19 |
+
.tab-btn { background: rgba(255,255,255,0.1); border: none; padding: 10px 20px; border-radius: 30px; color: white; cursor: pointer; transition: 0.2s; }
|
| 20 |
+
.tab-btn.active { background: #25D366; color: black; }
|
| 21 |
+
.tab-pane { display: none; }
|
| 22 |
+
.tab-pane.active { display: block; }
|
| 23 |
+
.stats { display: flex; gap: 20px; margin-bottom: 30px; flex-wrap: wrap; }
|
| 24 |
+
.stat-card { background: rgba(255,255,255,0.1); backdrop-filter: blur(10px); border-radius: 20px; padding: 20px; min-width: 150px; text-align: center; }
|
| 25 |
+
.stat-card h3 { color: #8e8e9e; font-size: 0.85rem; margin-bottom: 8px; }
|
| 26 |
+
.stat-card .number { font-size: 2rem; font-weight: 700; color: #25D366; }
|
| 27 |
+
.projects-table, .services-table { background: rgba(255,255,255,0.05); border-radius: 20px; overflow-x: auto; margin-top: 20px; }
|
| 28 |
+
table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
|
| 29 |
+
th, td { padding: 10px 8px; text-align: left; border-bottom: 1px solid rgba(255,255,255,0.1); color: #e0e0e0; vertical-align: top; }
|
| 30 |
+
th { background: rgba(0,0,0,0.3); font-weight: 600; color: #25D366; position: sticky; top: 0; }
|
| 31 |
+
.status-badge { display: inline-block; padding: 4px 12px; border-radius: 20px; font-size: 0.7rem; font-weight: 500; }
|
| 32 |
+
.status-pending { background: #ffc107; color: #333; }
|
| 33 |
+
.status-progress { background: #17a2b8; color: white; }
|
| 34 |
+
.status-completed { background: #28a745; color: white; }
|
| 35 |
+
.status-declined { background: #dc3545; color: white; }
|
| 36 |
+
button, .btn { background: #25D366; border: none; padding: 6px 12px; border-radius: 8px; color: white; cursor: pointer; margin: 2px; font-size: 0.7rem; }
|
| 37 |
+
.btn-danger { background: #dc3545; }
|
| 38 |
+
.btn-warning { background: #ffc107; color: #333; }
|
| 39 |
+
.btn-sm { padding: 4px 8px; font-size: 0.65rem; }
|
| 40 |
+
.btn-info { background: #17a2b8; }
|
| 41 |
+
input, textarea, select { background: #1e2a3a; border: 1px solid #2a2a35; border-radius: 8px; padding: 8px; color: white; margin: 5px 0; width: 100%; }
|
| 42 |
+
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); justify-content: center; align-items: center; z-index: 1000; }
|
| 43 |
+
.modal-content { background: #1e1e28; border-radius: 20px; padding: 20px; width: 650px; max-width: 90%; max-height: 80vh; overflow-y: auto; }
|
| 44 |
+
.refresh-btn { background: #2a2a35; margin-bottom: 10px; padding: 8px 16px; }
|
| 45 |
+
.flex-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
|
| 46 |
+
.detail-row { margin-bottom: 12px; border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 6px; }
|
| 47 |
+
.detail-label { font-weight: 600; color: #25D366; width: 140px; display: inline-block; vertical-align: top; }
|
| 48 |
+
.detail-value { color: #ddd; word-break: break-word; display: inline-block; width: calc(100% - 150px); }
|
| 49 |
+
.media-image { max-width: 200px; max-height: 200px; border-radius: 8px; margin-top: 8px; }
|
| 50 |
+
.delete-all-btn { background: #dc3545; margin-left: 20px; padding: 8px 16px; }
|
| 51 |
+
</style>
|
| 52 |
+
</head>
|
| 53 |
+
<body>
|
| 54 |
+
<div class="container">
|
| 55 |
+
<h1><i class="fas fa-crown"></i> Elite Visuals – Admin Panel</h1>
|
| 56 |
+
<div class="flex-row" style="justify-content: space-between;">
|
| 57 |
+
<p class="subtitle">Manage projects, extra services, and client communications</p>
|
| 58 |
+
<button id="deleteAllBtn" class="btn delete-all-btn"><i class="fas fa-trash-alt"></i> Delete All Data</button>
|
| 59 |
+
</div>
|
| 60 |
+
|
| 61 |
+
<div class="tabs">
|
| 62 |
+
<button class="tab-btn active" data-tab="projects">📋 Projects</button>
|
| 63 |
+
<button class="tab-btn" data-tab="services">⚙️ Extra Services</button>
|
| 64 |
+
</div>
|
| 65 |
+
|
| 66 |
+
<!-- Projects Tab -->
|
| 67 |
+
<div id="projectsTab" class="tab-pane active">
|
| 68 |
+
<div class="stats" id="statsContainer">
|
| 69 |
+
<div class="stat-card"><h3>Total Projects</h3><div class="number" id="totalProjects">0</div></div>
|
| 70 |
+
<div class="stat-card"><h3>Pending</h3><div class="number" id="pendingCount">0</div></div>
|
| 71 |
+
<div class="stat-card"><h3>In Progress</h3><div class="number" id="progressCount">0</div></div>
|
| 72 |
+
<div class="stat-card"><h3>Completed</h3><div class="number" id="completedCount">0</div></div>
|
| 73 |
+
<div class="stat-card"><h3>Declined</h3><div class="number" id="declinedCount">0</div></div>
|
| 74 |
+
</div>
|
| 75 |
+
<button class="refresh-btn" id="refreshProjectsBtn"><i class="fas fa-sync-alt"></i> Refresh Projects</button>
|
| 76 |
+
<div class="projects-table">
|
| 77 |
+
<table id="projectsTable">
|
| 78 |
+
<thead>
|
| 79 |
+
<tr>
|
| 80 |
+
<th>Project ID</th><th>Domain</th><th>Pages</th><th>E-com</th><th>Chatbot</th><th>SEO</th>
|
| 81 |
+
<th>Extras</th><th>📞 Mobile</th><th>✉️ Email</th>
|
| 82 |
+
<th>Price</th><th>Timeline</th><th>Status</th><th>Actions</th>
|
| 83 |
+
</tr>
|
| 84 |
+
</thead>
|
| 85 |
+
<tbody id="projectsTableBody"><tr><td colspan="13" class="loading">Loading...<\/td><\/tr></tbody>
|
| 86 |
+
</table>
|
| 87 |
+
</div>
|
| 88 |
+
</div>
|
| 89 |
+
|
| 90 |
+
<!-- Services Tab -->
|
| 91 |
+
<div id="servicesTab" class="tab-pane">
|
| 92 |
+
<div class="flex-row" style="margin-bottom: 20px;">
|
| 93 |
+
<button id="addServiceBtn" class="btn"><i class="fas fa-plus"></i> Add Single Service</button>
|
| 94 |
+
<button id="bulkAddServiceBtn" class="btn"><i class="fas fa-layer-group"></i> Bulk Import Services</button>
|
| 95 |
+
<button class="refresh-btn" id="refreshServicesBtn"><i class="fas fa-sync-alt"></i> Refresh Services</button>
|
| 96 |
+
</div>
|
| 97 |
+
<div class="services-table">
|
| 98 |
+
<table id="servicesTable">
|
| 99 |
+
<thead><tr><th>Key</th><th>Name</th><th>Price (PKR)</th><th>Timeline (days)</th><th>Actions</th></tr></thead>
|
| 100 |
+
<tbody id="servicesTableBody"><td><td colspan="5" class="loading">Loading...<\/td><\/tr></tbody>
|
| 101 |
+
</table>
|
| 102 |
+
</div>
|
| 103 |
+
</div>
|
| 104 |
+
</div>
|
| 105 |
+
|
| 106 |
+
<!-- Modals (same as before) -->
|
| 107 |
+
<div id="detailsModal" class="modal"><div class="modal-content"><h3>📋 Project Full Details</h3><div id="detailsContent"></div><div class="detail-row"><span class="detail-label">Admin Message:</span> <textarea id="editAdminMessage" rows="2"></textarea></div><div class="flex-row"><button id="detailsSaveBtn" class="btn">Save Message</button><button id="detailsCloseBtn" class="btn-warning">Close</button></div></div></div>
|
| 108 |
+
<div id="serviceModal" class="modal"><div class="modal-content"><h3 id="modalTitle">Add Service</h3><input type="text" id="serviceKey" style="display:none;"><input type="text" id="serviceName" placeholder="Service Name"><input type="number" id="servicePrice" placeholder="Price (PKR)"><input type="number" id="serviceTimeline" placeholder="Timeline (days)"><div class="flex-row"><button id="modalCancelBtn" class="btn-warning">Cancel</button><button id="modalSaveBtn" class="btn">Save</button></div></div></div>
|
| 109 |
+
<div id="bulkModal" class="modal"><div class="modal-content"><h3>Bulk Import Services</h3><textarea id="bulkServicesInput" rows="8" placeholder="Name | Price | Timeline"></textarea><div class="flex-row"><button id="bulkCancelBtn" class="btn-warning">Cancel</button><button id="bulkImportBtn" class="btn">Import</button></div><div id="bulkResult"></div></div></div>
|
| 110 |
+
<div id="declineModal" class="modal"><div class="modal-content"><h3>Decline Project</h3><textarea id="declineReason" rows="3"></textarea><div class="flex-row"><button id="declineCancelBtn" class="btn-warning">Cancel</button><button id="declineConfirmBtn" class="btn-danger">Confirm Decline</button></div></div></div>
|
| 111 |
+
<div id="deleteConfirmModal" class="modal"><div class="modal-content"><h3>⚠️ Delete All Data</h3><p>This will permanently delete ALL projects. Are you sure?</p><div class="flex-row"><button id="deleteConfirmNo" class="btn-warning">Cancel</button><button id="deleteConfirmYes" class="btn-danger">Yes, Delete Everything</button></div></div></div>
|
| 112 |
+
|
| 113 |
+
<script>
|
| 114 |
+
const firebaseConfig = {
|
| 115 |
+
apiKey: "AIzaSyDaZ-JNzw--zGqWN1wweC4csDAE_GKUklw",
|
| 116 |
+
authDomain: "chat-bot-80c6e.firebaseapp.com",
|
| 117 |
+
databaseURL: "https://chat-bot-80c6e-default-rtdb.firebaseio.com",
|
| 118 |
+
projectId: "chat-bot-80c6e",
|
| 119 |
+
storageBucket: "chat-bot-80c6e.firebasestorage.app",
|
| 120 |
+
messagingSenderId: "363352177618",
|
| 121 |
+
appId: "1:363352177618:web:4a75bd8c66e53f1b05a60b"
|
| 122 |
+
};
|
| 123 |
+
firebase.initializeApp(firebaseConfig);
|
| 124 |
+
const database = firebase.database();
|
| 125 |
+
|
| 126 |
+
let currentProjects = [];
|
| 127 |
+
let currentServices = {};
|
| 128 |
+
let currentDetailsProjectId = null;
|
| 129 |
+
|
| 130 |
+
// ---------- Projects ----------
|
| 131 |
+
async function loadProjects() {
|
| 132 |
+
const tbody = document.getElementById('projectsTableBody');
|
| 133 |
+
tbody.innerHTML = '<tr><td colspan="13" class="loading">Loading...<\/td><\/tr>';
|
| 134 |
+
const snapshot = await database.ref('projects').once('value');
|
| 135 |
+
const data = snapshot.val();
|
| 136 |
+
currentProjects = data ? Object.values(data) : [];
|
| 137 |
+
renderProjects();
|
| 138 |
+
updateStats();
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
function renderProjects() {
|
| 142 |
+
const tbody = document.getElementById('projectsTableBody');
|
| 143 |
+
if (!currentProjects.length) { tbody.innerHTML = '<tr><td colspan="13" class="loading">No projects found<\/td><\/tr>'; return; }
|
| 144 |
+
tbody.innerHTML = '';
|
| 145 |
+
currentProjects.forEach(proj => {
|
| 146 |
+
const req = proj.requirements || {};
|
| 147 |
+
const extras = (req.extra_features || []).join(', ') || 'None';
|
| 148 |
+
const statusClass = `status-${proj.status}`;
|
| 149 |
+
const statusText = proj.status==='pending'?'⏳ Pending':(proj.status==='in-progress'?'🔄 In Progress':(proj.status==='completed'?'✅ Completed':'❌ Declined'));
|
| 150 |
+
const mobile = req.mobile || '—';
|
| 151 |
+
const email = req.email || '—';
|
| 152 |
+
const row = document.createElement('tr');
|
| 153 |
+
row.innerHTML = `
|
| 154 |
+
<td><code>${proj.project_id}</code></td>
|
| 155 |
+
<td>${req.domain ? '✅' : '❌'}</td>
|
| 156 |
+
<td>${req.pages || 5}</td>
|
| 157 |
+
<td>${req.ecommerce ? '✅' : '❌'}</td>
|
| 158 |
+
<td>${req.chatbot ? '✅' : '❌'}</td>
|
| 159 |
+
<td>${req.seo ? '✅' : '❌'}</td>
|
| 160 |
+
<td><small>${extras}</small></td>
|
| 161 |
+
<td>${mobile}</td><td>${email}</td>
|
| 162 |
+
<td>PKR ${(proj.calculated_price||0).toLocaleString()}</td>
|
| 163 |
+
<td>${proj.calculated_timeline||0} days</td>
|
| 164 |
+
<td><span class="status-badge ${statusClass}">${statusText}</span></td>
|
| 165 |
+
<td>
|
| 166 |
+
<select onchange="updateStatusDirect('${proj.project_id}', this.value)">
|
| 167 |
+
<option ${proj.status==='pending'?'selected':''}>pending</option>
|
| 168 |
+
<option ${proj.status==='in-progress'?'selected':''}>in-progress</option>
|
| 169 |
+
<option ${proj.status==='completed'?'selected':''}>completed</option>
|
| 170 |
+
<option ${proj.status==='declined'?'selected':''}>declined</option>
|
| 171 |
+
</select>
|
| 172 |
+
<button class="btn-sm" onclick="openDeclineModal('${proj.project_id}')">Decline</button>
|
| 173 |
+
<button class="btn-sm btn-info" onclick="openDetailsModal('${proj.project_id}')">Details</button>
|
| 174 |
+
</td>
|
| 175 |
+
`;
|
| 176 |
+
tbody.appendChild(row);
|
| 177 |
+
});
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
function updateStats() {
|
| 181 |
+
const total = currentProjects.length;
|
| 182 |
+
const pending = currentProjects.filter(p=>p.status==='pending').length;
|
| 183 |
+
const progress = currentProjects.filter(p=>p.status==='in-progress').length;
|
| 184 |
+
const completed = currentProjects.filter(p=>p.status==='completed').length;
|
| 185 |
+
const declined = currentProjects.filter(p=>p.status==='declined').length;
|
| 186 |
+
document.getElementById('totalProjects').innerText = total;
|
| 187 |
+
document.getElementById('pendingCount').innerText = pending;
|
| 188 |
+
document.getElementById('progressCount').innerText = progress;
|
| 189 |
+
document.getElementById('completedCount').innerText = completed;
|
| 190 |
+
document.getElementById('declinedCount').innerText = declined;
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
window.updateStatusDirect = async (id, status) => {
|
| 194 |
+
await database.ref(`projects/${id}`).update({ status, updated_at: new Date().toISOString() });
|
| 195 |
+
loadProjects();
|
| 196 |
+
};
|
| 197 |
+
let declineId = null;
|
| 198 |
+
window.openDeclineModal = (id) => { declineId = id; document.getElementById('declineModal').style.display='flex'; };
|
| 199 |
+
document.getElementById('declineCancelBtn').onclick = () => document.getElementById('declineModal').style.display='none';
|
| 200 |
+
document.getElementById('declineConfirmBtn').onclick = async () => {
|
| 201 |
+
const reason = document.getElementById('declineReason').value;
|
| 202 |
+
await database.ref(`projects/${declineId}`).update({ status:'declined', admin_message:reason, updated_at:new Date().toISOString() });
|
| 203 |
+
document.getElementById('declineModal').style.display='none';
|
| 204 |
+
loadProjects();
|
| 205 |
+
};
|
| 206 |
+
window.openDetailsModal = async (id) => {
|
| 207 |
+
currentDetailsProjectId = id;
|
| 208 |
+
const snap = await database.ref(`projects/${id}`).once('value');
|
| 209 |
+
const proj = snap.val();
|
| 210 |
+
if(!proj) return;
|
| 211 |
+
const req = proj.requirements || {};
|
| 212 |
+
let html = `
|
| 213 |
+
<div class="detail-row"><span class="detail-label">Project ID:</span> <span class="detail-value">${proj.project_id}</span></div>
|
| 214 |
+
<div class="detail-row"><span class="detail-label">Status:</span> <span class="detail-value">${proj.status}</span></div>
|
| 215 |
+
<div class="detail-row"><span class="detail-label">Created:</span> <span class="detail-value">${new Date(proj.created_at).toLocaleString()}</span></div>
|
| 216 |
+
<div class="detail-row"><span class="detail-label">Last Updated:</span> <span class="detail-value">${new Date(proj.updated_at).toLocaleString()}</span></div>
|
| 217 |
+
<div class="detail-row"><span class="detail-label">Mobile:</span> <span class="detail-value">${req.mobile||'—'}</span></div>
|
| 218 |
+
<div class="detail-row"><span class="detail-label">Email:</span> <span class="detail-value">${req.email||'—'}</span></div>
|
| 219 |
+
<div class="detail-row"><span class="detail-label">Domain:</span> <span class="detail-value">${req.domain?'Yes (+PKR 5,000)':'No'}</span></div>
|
| 220 |
+
<div class="detail-row"><span class="detail-label">Pages:</span> <span class="detail-value">${req.pages||5}</span></div>
|
| 221 |
+
<div class="detail-row"><span class="detail-label">E‑commerce:</span> <span class="detail-value">${req.ecommerce?'Yes (+PKR 50,000)':'No'}</span></div>
|
| 222 |
+
<div class="detail-row"><span class="detail-label">Chatbot:</span> <span class="detail-value">${req.chatbot?'Yes (+PKR 30,000)':'No'}</span></div>
|
| 223 |
+
<div class="detail-row"><span class="detail-label">SEO:</span> <span class="detail-value">${req.seo?'Yes (+PKR 25,000)':'No'}</span></div>
|
| 224 |
+
<div class="detail-row"><span class="detail-label">Extra Features:</span> <span class="detail-value">${(req.extra_features||[]).join(', ')||'None'}</span></div>
|
| 225 |
+
<div class="detail-row"><span class="detail-label">Inventory:</span> <span class="detail-value">${req.inventory||'No'}</span></div>
|
| 226 |
+
<div class="detail-row"><span class="detail-label">Database:</span> <span class="detail-value">${req.data||'No'}</span></div>
|
| 227 |
+
<div class="detail-row"><span class="detail-label">Purpose:</span> <span class="detail-value">${req.purpose||'—'}</span></div>
|
| 228 |
+
<div class="detail-row"><span class="detail-label">Theme:</span> <span class="detail-value">${req.theme||'—'}</span></div>
|
| 229 |
+
<div class="detail-row"><span class="detail-label">Content:</span> <span class="detail-value">${req.content||'—'}</span></div>
|
| 230 |
+
`;
|
| 231 |
+
if(req.media_text) html += `<div class="detail-row"><span class="detail-label">Client Notes:</span> <span class="detail-value">${req.media_text}</span></div>`;
|
| 232 |
+
if(req.media_image) html += `<div class="detail-row"><span class="detail-label">Uploaded Image:</span> <span class="detail-value"><img src="${req.media_image}" class="media-image"></span></div>`;
|
| 233 |
+
html += `<div class="detail-row"><span class="detail-label">Total Price:</span> <span class="detail-value">PKR ${(proj.calculated_price||0).toLocaleString()}</span></div>
|
| 234 |
+
<div class="detail-row"><span class="detail-label">Total Timeline:</span> <span class="detail-value">${proj.calculated_timeline||0} days</span></div>`;
|
| 235 |
+
document.getElementById('detailsContent').innerHTML = html;
|
| 236 |
+
document.getElementById('editAdminMessage').value = proj.admin_message||'';
|
| 237 |
+
document.getElementById('detailsModal').style.display='flex';
|
| 238 |
+
};
|
| 239 |
+
document.getElementById('detailsCloseBtn').onclick = () => document.getElementById('detailsModal').style.display='none';
|
| 240 |
+
document.getElementById('detailsSaveBtn').onclick = async () => {
|
| 241 |
+
const msg = document.getElementById('editAdminMessage').value;
|
| 242 |
+
await database.ref(`projects/${currentDetailsProjectId}`).update({ admin_message: msg, updated_at: new Date().toISOString() });
|
| 243 |
+
document.getElementById('detailsModal').style.display='none';
|
| 244 |
+
loadProjects();
|
| 245 |
+
};
|
| 246 |
+
|
| 247 |
+
// ---------- Extra Services ----------
|
| 248 |
+
async function loadServices() {
|
| 249 |
+
const tbody = document.getElementById('servicesTableBody');
|
| 250 |
+
tbody.innerHTML = '<tr><td colspan="5" class="loading">Loading...<\/td><\/tr>';
|
| 251 |
+
const snap = await database.ref('extra_services').once('value');
|
| 252 |
+
currentServices = snap.val() || {};
|
| 253 |
+
renderServices();
|
| 254 |
+
}
|
| 255 |
+
function renderServices() {
|
| 256 |
+
const tbody = document.getElementById('servicesTableBody');
|
| 257 |
+
if (!Object.keys(currentServices).length) { tbody.innerHTML = '<tr><td colspan="5" class="loading">No extra services found<\/td><\/tr>'; return; }
|
| 258 |
+
tbody.innerHTML = '';
|
| 259 |
+
for (const [k, svc] of Object.entries(currentServices)) {
|
| 260 |
+
const row = document.createElement('tr');
|
| 261 |
+
row.innerHTML = `
|
| 262 |
+
<td><code>${k}</code></td>
|
| 263 |
+
<td>${svc.name}</td>
|
| 264 |
+
<td>PKR ${svc.price?.toLocaleString()||0}</td>
|
| 265 |
+
<td>${svc.timeline||0} days</td>
|
| 266 |
+
<td>
|
| 267 |
+
<button class="btn-sm" onclick="editService('${k}')">Edit</button>
|
| 268 |
+
<button class="btn-sm btn-danger" onclick="deleteService('${k}')">Delete</button>
|
| 269 |
+
</td>
|
| 270 |
+
`;
|
| 271 |
+
tbody.appendChild(row);
|
| 272 |
+
}
|
| 273 |
+
}
|
| 274 |
+
window.editService = (k) => {
|
| 275 |
+
const svc = currentServices[k];
|
| 276 |
+
document.getElementById('modalTitle').innerText = 'Edit Service';
|
| 277 |
+
document.getElementById('serviceKey').value = k;
|
| 278 |
+
document.getElementById('serviceName').value = svc.name;
|
| 279 |
+
document.getElementById('servicePrice').value = svc.price;
|
| 280 |
+
document.getElementById('serviceTimeline').value = svc.timeline;
|
| 281 |
+
document.getElementById('serviceModal').style.display='flex';
|
| 282 |
+
};
|
| 283 |
+
window.deleteService = async (k) => {
|
| 284 |
+
if (confirm(`Delete service "${k}"?`)) {
|
| 285 |
+
await database.ref(`extra_services/${k}`).remove();
|
| 286 |
+
loadServices();
|
| 287 |
+
}
|
| 288 |
+
};
|
| 289 |
+
document.getElementById('addServiceBtn').onclick = () => {
|
| 290 |
+
document.getElementById('modalTitle').innerText = 'Add Single Service';
|
| 291 |
+
document.getElementById('serviceKey').value = '';
|
| 292 |
+
document.getElementById('serviceName').value = '';
|
| 293 |
+
document.getElementById('servicePrice').value = '';
|
| 294 |
+
document.getElementById('serviceTimeline').value = '';
|
| 295 |
+
document.getElementById('serviceModal').style.display='flex';
|
| 296 |
+
};
|
| 297 |
+
document.getElementById('modalCancelBtn').onclick = () => document.getElementById('serviceModal').style.display='none';
|
| 298 |
+
document.getElementById('modalSaveBtn').onclick = async () => {
|
| 299 |
+
let key = document.getElementById('serviceKey').value.trim();
|
| 300 |
+
let name = document.getElementById('serviceName').value.trim();
|
| 301 |
+
let price = parseInt(document.getElementById('servicePrice').value) || 0;
|
| 302 |
+
let timeline = parseInt(document.getElementById('serviceTimeline').value) || 0;
|
| 303 |
+
if (!name) { alert('Service name required'); return; }
|
| 304 |
+
const finalKey = key || name.toLowerCase().replace(/ /g,'_');
|
| 305 |
+
await database.ref(`extra_services/${finalKey}`).set({ name, price, timeline, display: `${name} (+PKR ${price.toLocaleString()}, +${timeline} days)` });
|
| 306 |
+
document.getElementById('serviceModal').style.display='none';
|
| 307 |
+
loadServices();
|
| 308 |
+
};
|
| 309 |
+
// Bulk import
|
| 310 |
+
document.getElementById('bulkAddServiceBtn').onclick = () => {
|
| 311 |
+
document.getElementById('bulkServicesInput').value = '';
|
| 312 |
+
document.getElementById('bulkResult').innerHTML = '';
|
| 313 |
+
document.getElementById('bulkModal').style.display='flex';
|
| 314 |
+
};
|
| 315 |
+
document.getElementById('bulkCancelBtn').onclick = () => document.getElementById('bulkModal').style.display='none';
|
| 316 |
+
document.getElementById('bulkImportBtn').onclick = async () => {
|
| 317 |
+
const lines = document.getElementById('bulkServicesInput').value.split(/\r?\n/);
|
| 318 |
+
let success=0, fail=0;
|
| 319 |
+
for (let line of lines) {
|
| 320 |
+
line = line.trim();
|
| 321 |
+
if (!line) continue;
|
| 322 |
+
const parts = line.split('|').map(p=>p.trim());
|
| 323 |
+
if (parts.length < 3) { fail++; continue; }
|
| 324 |
+
const name = parts[0];
|
| 325 |
+
const price = parseInt(parts[1]);
|
| 326 |
+
const timeline = parseInt(parts[2]);
|
| 327 |
+
if (isNaN(price) || isNaN(timeline)) { fail++; continue; }
|
| 328 |
+
const key = name.toLowerCase().replace(/ /g,'_');
|
| 329 |
+
try {
|
| 330 |
+
await database.ref(`extra_services/${key}`).set({ name, price, timeline, display: `${name} (+PKR ${price.toLocaleString()}, +${timeline} days)` });
|
| 331 |
+
success++;
|
| 332 |
+
} catch(e) { fail++; }
|
| 333 |
+
}
|
| 334 |
+
document.getElementById('bulkResult').innerHTML = `✅ Imported: ${success}, ❌ Failed: ${fail}`;
|
| 335 |
+
if (success) loadServices();
|
| 336 |
+
setTimeout(()=>document.getElementById('bulkModal').style.display='none', 1500);
|
| 337 |
+
};
|
| 338 |
+
// Delete all data - fixed fetch
|
| 339 |
+
const deleteModal = document.getElementById('deleteConfirmModal');
|
| 340 |
+
document.getElementById('deleteAllBtn').onclick = () => deleteModal.style.display='flex';
|
| 341 |
+
document.getElementById('deleteConfirmNo').onclick = () => deleteModal.style.display='none';
|
| 342 |
+
document.getElementById('deleteConfirmYes').onclick = async () => {
|
| 343 |
+
deleteModal.style.display='none';
|
| 344 |
+
if (confirm("⚠️ This will delete ALL projects. Are you absolutely sure?")) {
|
| 345 |
+
try {
|
| 346 |
+
const response = await fetch('/api/delete_all_projects?confirm=YES', { method: 'DELETE' });
|
| 347 |
+
if (!response.ok) {
|
| 348 |
+
const errorText = await response.text();
|
| 349 |
+
throw new Error(`Server responded with ${response.status}: ${errorText}`);
|
| 350 |
+
}
|
| 351 |
+
const data = await response.json();
|
| 352 |
+
alert(data.message || "All projects deleted successfully");
|
| 353 |
+
loadProjects();
|
| 354 |
+
} catch (err) {
|
| 355 |
+
console.error("Delete error:", err);
|
| 356 |
+
alert("Error deleting projects: " + err.message + "\n\nPlease make sure you are accessing the admin panel via the same origin (e.g., https://your-space.hf.space/admin) and that the backend route exists.");
|
| 357 |
+
}
|
| 358 |
+
}
|
| 359 |
+
};
|
| 360 |
+
// Refresh buttons
|
| 361 |
+
document.getElementById('refreshProjectsBtn').addEventListener('click', loadProjects);
|
| 362 |
+
document.getElementById('refreshServicesBtn').addEventListener('click', loadServices);
|
| 363 |
+
// Tab switching
|
| 364 |
+
document.querySelectorAll('.tab-btn').forEach(btn => {
|
| 365 |
+
btn.addEventListener('click', () => {
|
| 366 |
+
document.querySelectorAll('.tab-btn').forEach(b=>b.classList.remove('active'));
|
| 367 |
+
btn.classList.add('active');
|
| 368 |
+
document.querySelectorAll('.tab-pane').forEach(p=>p.classList.remove('active'));
|
| 369 |
+
document.getElementById(`${btn.dataset.tab}Tab`).classList.add('active');
|
| 370 |
+
if (btn.dataset.tab === 'services') loadServices();
|
| 371 |
+
});
|
| 372 |
+
});
|
| 373 |
+
loadProjects();
|
| 374 |
+
loadServices();
|
| 375 |
+
</script>
|
| 376 |
+
</body>
|
| 377 |
+
</html>
|