Files
cemento/templates/index.html
2026-01-20 09:40:45 +01:00

60 lines
3.0 KiB
HTML

<!DOCTYPE html>
<html lang="it">
<head>
<meta charset="UTF-8">
<title>Calcolo Calcestruzzo v2.1</title>
<style>
body { font-family: sans-serif; background-color: #f4f7f6; padding: 20px; }
.container { display: flex; max-width: 900px; margin: auto; background: white; padding: 20px; border: 1px solid #ccc; gap: 20px; }
.panel { flex: 1; }
.output { border: 1px solid #999; padding: 15px; min-height: 350px; white-space: pre-wrap; }
input, select { padding: 4px; border: 1px solid #ccc; width: 100%; box-sizing: border-box; }
.btn-stampa { padding: 10px; cursor: pointer; background: #fff3e0; border: 1px solid #999; flex: 1; }
</style>
</head>
<body>
<div class="container">
<div class="panel">
<form method="POST">
<table>
<tr><td>Larghezza</td><td><input type="text" name="l" value="{{form.get('l','1')}}"></td><td><select name="ul"><option value="m">m</option></select></td></tr>
<tr><td>Profondità</td><td><input type="text" name="p" value="{{form.get('p','1')}}"></td><td><select name="up"><option value="m">m</option></select></td></tr>
<tr><td>Altezza</td><td><input type="text" name="a" value="{{form.get('a','1')}}"></td><td><select name="ua"><option value="m">m</option></select></td></tr>
<tr><td colspan="3"><hr></td></tr>
<tr><td>P. Cemento</td><td><input type="text" name="p_cem" value="{{form.get('p_cem','1')}}"></td></tr>
<tr><td>P. Sabbia</td><td><input type="text" name="p_sab" value="{{form.get('p_sab','3')}}"></td></tr>
<tr><td>P. Ghiaia</td><td><input type="text" name="p_ghi" value="{{form.get('p_ghi','5')}}"></td></tr>
</table>
<button type="submit" style="width:100%; padding:10px;">Calcola</button>
</form>
</div>
<div class="panel output">
<strong>Risultati:</strong>
{% if res %}
Volume: {{ res.vol }} m3 | Peso: {{ res.peso }} kg
Cemento: {{ res.s_cem }} sacchetti
Sabbia: {{ res.s_sab }} sacchetti
Ghiaia: {{ res.s_ghi }} sacchetti
<strong>TOTALE: {{ res.tot_sacc }} sacchetti</strong>
<div style="display:flex; gap:10px; margin-top:20px;">
<button type="button" onclick="stampa()" class="btn-stampa">Stampa PDF (CUPS)</button>
</div>
<div id="status" style="margin-top:10px; font-weight:bold; text-align:center;"></div>
{% endif %}
</div>
</div>
<script>
function stampa() {
const s = document.getElementById('status');
s.innerText = "Invio...";
const fd = new FormData();
fd.append('v', '{{res.vol if res else ""}}');
fd.append('p', '{{res.peso if res else ""}}');
fd.append('ts', '{{res.tot_sacc if res else ""}}');
fetch('/stampa_pdf', { method: 'POST', body: fd })
.then(r => r.text()).then(m => { s.innerText = m; s.style.color = m.includes("OK") ? "green" : "red"; });
}
</script>
</body>
</html>