Created
July 27, 2025 19:26
-
-
Save thinkphp/d08397c124edc5550244649fe866bf32 to your computer and use it in GitHub Desktop.
admin newsletter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="ro"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Newsletter Admin - Abonați</title> | |
<style> | |
body { | |
font-family: Arial, sans-serif; | |
margin: 0; | |
padding: 20px; | |
background-color: #f5f5f5; | |
} | |
.container { | |
max-width: 1000px; | |
margin: 0 auto; | |
background: white; | |
padding: 20px; | |
border-radius: 8px; | |
box-shadow: 0 2px 10px rgba(0,0,0,0.1); | |
} | |
h1 { | |
color: #333; | |
text-align: center; | |
margin-bottom: 30px; | |
} | |
.loading { | |
text-align: center; | |
padding: 50px; | |
color: #666; | |
} | |
.error { | |
background: #ffebee; | |
color: #c62828; | |
padding: 15px; | |
border-radius: 4px; | |
margin: 20px 0; | |
border-left: 4px solid #c62828; | |
} | |
table { | |
width: 100%; | |
border-collapse: collapse; | |
margin-top: 20px; | |
} | |
th, td { | |
padding: 12px; | |
text-align: left; | |
border-bottom: 1px solid #ddd; | |
} | |
th { | |
background-color: #f8f9fa; | |
font-weight: bold; | |
color: #333; | |
} | |
tr:hover { | |
background-color: #f5f5f5; | |
} | |
.email { | |
font-family: monospace; | |
color: #0066cc; | |
} | |
.date { | |
color: #666; | |
font-size: 0.9em; | |
} | |
.ip { | |
font-family: monospace; | |
color: #999; | |
font-size: 0.85em; | |
} | |
.no-data { | |
text-align: center; | |
padding: 50px; | |
color: #666; | |
} | |
.refresh-btn { | |
background: #007bff; | |
color: white; | |
border: none; | |
padding: 10px 20px; | |
border-radius: 4px; | |
cursor: pointer; | |
margin-bottom: 20px; | |
} | |
.refresh-btn:hover { | |
background: #0056b3; | |
} | |
@media (max-width: 768px) { | |
.container { | |
padding: 10px; | |
} | |
table { | |
font-size: 0.9em; | |
} | |
th, td { | |
padding: 8px 4px; | |
} | |
} | |
</style> | |
</head> | |
<body> | |
<div class="container"> | |
<h1>Newsletter - Subscribers</h1> | |
<button class="refresh-btn" onclick="loadSubscribers()">🔄 Actualizează</button> | |
<div id="content"> | |
<div class="loading">Se încarcă...</div> | |
</div> | |
</div> | |
<script> | |
// Load data when page loads | |
document.addEventListener('DOMContentLoaded', loadSubscribers); | |
async function loadSubscribers() { | |
const content = document.getElementById('content'); | |
content.innerHTML = '<div class="loading">Se încarcă...</div>'; | |
try { | |
const response = await fetch('newsletter.php?admin=view'); | |
const data = await response.json(); | |
if (data.success) { | |
displayTable(data.emails); | |
} else { | |
content.innerHTML = ` | |
<div class="error"> | |
<strong>Eroare:</strong> ${data.message} | |
</div> | |
`; | |
} | |
} catch (error) { | |
content.innerHTML = ` | |
<div class="error"> | |
<strong>Eroare de conexiune:</strong> ${error.message} | |
</div> | |
`; | |
} | |
} | |
function displayTable(subscribers) { | |
const content = document.getElementById('content'); | |
if (subscribers.length === 0) { | |
content.innerHTML = ` | |
<div class="no-data"> | |
<h3>Nu există abonați</h3> | |
<p>Încă nu s-a abonat nimeni la newsletter.</p> | |
</div> | |
`; | |
return; | |
} | |
const tableHTML = ` | |
<p><strong>Total abonați:</strong> ${subscribers.length}</p> | |
<table> | |
<thead> | |
<tr> | |
<th>ID</th> | |
<th>Email</th> | |
<th>Data Abonării</th> | |
<th>IP Address</th> | |
</tr> | |
</thead> | |
<tbody> | |
${subscribers.map(subscriber => ` | |
<tr> | |
<td>${subscriber.id}</td> | |
<td class="email">${subscriber.email}</td> | |
<td class="date">${formatDate(subscriber.created_at)}</td> | |
<td class="ip">${subscriber.ip_address}</td> | |
</tr> | |
`).join('')} | |
</tbody> | |
</table> | |
`; | |
content.innerHTML = tableHTML; | |
} | |
function formatDate(dateString) { | |
const date = new Date(dateString); | |
return date.toLocaleString('ro-RO'); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment