add print codes button
This commit is contained in:
parent
b6d1cbec67
commit
c6f5baae6e
34
index.html
34
index.html
@ -123,7 +123,10 @@ body{font:17px/1.6 -apple-system,BlinkMacSystemFont,"Segoe UI",Inter,system-ui,s
|
||||
<button type="submit" class="btn btn-green">Зарегистрировать родителя</button>
|
||||
</form>
|
||||
|
||||
<h4 style="margin-bottom:16px">Зарегистрированные родители:</h4>
|
||||
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:16px;flex-wrap:wrap;gap:12px">
|
||||
<h4 style="margin:0">Зарегистрированные родители:</h4>
|
||||
<button class="btn" onclick="printCodes()" style="padding:8px 16px;font-size:14px">🖨️ Распечатать коды</button>
|
||||
</div>
|
||||
<div id="parents-list" style="margin-bottom:32px"></div>
|
||||
</div>
|
||||
|
||||
@ -456,6 +459,35 @@ function deleteParent(id) {
|
||||
}
|
||||
}
|
||||
|
||||
function printCodes() {
|
||||
if (parents.length === 0) {
|
||||
alert('Пока нет зарегистрированных родителей!');
|
||||
return;
|
||||
}
|
||||
const content = parents.map(p =>
|
||||
`${p.name} (${p.phone}) — КОД: ${p.code} (лимит ${p.limit}₸)`
|
||||
).join('\n\n');
|
||||
|
||||
const printWindow = window.open('', '', 'width=600,height=400');
|
||||
printWindow.document.write(`
|
||||
<html><head><title>Коды родителей</title>
|
||||
<style>
|
||||
body{font-family:Arial,sans-serif;padding:40px}
|
||||
h1{color:#0F1218}
|
||||
.code{background:#E8FCFF;padding:15px;margin:10px 0;border-radius:8px;font-size:18px}
|
||||
.code strong{color:#00E5FF;font-size:24px}
|
||||
</style>
|
||||
</head><body>
|
||||
<h1>🏪 Школьный магазин — Коды родителей</h1>
|
||||
<p style="color:#5B6573">Распечатайте этот список и повесьте на кассе для проверки</p>
|
||||
${parents.map(p => `<div class="code"><strong>КОД: ${p.code}</strong><br>${p.name} (${p.phone})<br>Лимит: ${p.limit}₸</div>`).join('')}
|
||||
<p style="margin-top:30px;color:#5B6573;font-size:14px">Распечатано: ${new Date().toLocaleString('ru-RU')}</p>
|
||||
</body></html>
|
||||
`);
|
||||
printWindow.document.close();
|
||||
printWindow.print();
|
||||
}
|
||||
|
||||
// === Добавление/удаление ===
|
||||
document.getElementById('add-form').addEventListener('submit', (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user