51 Commits
v1.0 ... v1.2

Author SHA1 Message Date
6a9c4233e2 Update templates/index.html 2026-01-20 14:53:25 +01:00
88a2ceda45 Update templates/index.html 2026-01-20 14:51:41 +01:00
0981083067 Update cemento.py 2026-01-20 14:51:07 +01:00
b75189fdbf Update cemento.py 2026-01-20 14:48:46 +01:00
94cee29e10 Update templates/index.html 2026-01-20 14:47:29 +01:00
d62e3edac6 Update cemento.py 2026-01-20 14:46:59 +01:00
cb9cfa9e8b Update templates/index.html 2026-01-20 14:43:50 +01:00
3865ddf8f3 Update cemento.py 2026-01-20 14:43:12 +01:00
6eb0c4411f Update templates/index.html 2026-01-20 14:38:24 +01:00
af7c622e2f Update cemento.py 2026-01-20 14:37:48 +01:00
c91289ef9f Update templates/index.html 2026-01-20 13:15:23 +01:00
7ba555890a Update cemento.py 2026-01-20 13:14:51 +01:00
a3d8d9bd0d Update templates/index.html 2026-01-20 13:13:02 +01:00
19ec78289b Update cemento.py 2026-01-20 13:12:36 +01:00
16170317d1 Update templates/index.html 2026-01-20 13:07:56 +01:00
4e3ea7fad8 Update cemento.py 2026-01-20 13:07:19 +01:00
6979a66912 Update templates/index.html 2026-01-20 12:42:30 +01:00
c30d198c3e Update cemento.py 2026-01-20 12:40:43 +01:00
1db2b46044 Update cemento.py 2026-01-20 11:59:23 +01:00
6f18621983 Update cemento.py 2026-01-20 11:57:32 +01:00
d80d816e1c Update cemento.py 2026-01-20 11:55:56 +01:00
fc9267c79c Update cemento.py 2026-01-20 11:04:33 +01:00
f7e7097612 Update cemento.py 2026-01-20 10:44:06 +01:00
5b72a63b8a Update cemento.py 2026-01-20 10:40:22 +01:00
673e88d6d3 Update templates/index.html 2026-01-20 09:40:45 +01:00
416c8feff1 Update cemento.py 2026-01-20 09:40:16 +01:00
c5f9763aeb Update templates/index.html 2026-01-20 09:37:43 +01:00
8bb39a4396 Update cemento.py 2026-01-20 09:37:12 +01:00
636863e207 Update templates/index.html 2026-01-20 09:34:02 +01:00
2093fe9fde Update cemento.py 2026-01-20 09:33:34 +01:00
3b2fbba025 Update templates/index.html 2026-01-20 09:30:42 +01:00
ae0294f774 Update cemento.py 2026-01-20 09:29:34 +01:00
0547260228 Update templates/index.html
Implementata stampa tramite CUPS
2026-01-20 09:22:21 +01:00
11d9df9606 Update cemento.py
Implementata Stamapa tramite CUPS
2026-01-20 09:21:19 +01:00
2749446249 Update cemento.py 2026-01-16 16:11:59 +01:00
71ce30307b Update cemento.py 2026-01-16 16:02:16 +01:00
242412dc19 Update cemento.py 2026-01-16 15:58:26 +01:00
c8c4496d4a Release v1.1 2026-01-16 11:47:41 +01:00
8a92767293 Versione 1.0 2026-01-15 17:54:24 +01:00
27aded61fd Update cemento.py 2026-01-15 16:30:54 +01:00
3e11847964 Release v1.0 2026-01-15 16:30:10 +01:00
d4596b2eeb Aggiornato codice 2026-01-15 16:26:25 +01:00
9eae600e81 Release v1.0 2026-01-15 16:20:48 +01:00
10c13225cc Release v1.0 2026-01-15 16:14:49 +01:00
adae2623e6 Release v1.0 2026-01-15 16:09:12 +01:00
df94568376 Release v1.0 2026-01-15 15:59:14 +01:00
1be5e787a3 Commit delle modifiche 2026-01-15 15:54:06 +01:00
14902379d8 Update templates/index.html 2026-01-15 15:48:28 +01:00
1ac313efa7 Update templates/index.html 2026-01-15 15:44:57 +01:00
002da8f77f Release v1.0 2026-01-15 15:34:34 +01:00
bd7b1d2533 Release v1.0 2026-01-15 15:32:14 +01:00
2 changed files with 81 additions and 117 deletions

View File

@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from flask import Flask, render_template, request, Response
import math
import subprocess
app = Flask(__name__)
@@ -26,7 +27,6 @@ def calcola(d):
kg = (p[m]/somma_p)*peso_tot if somma_p > 0 else 0
s_esatti = kg/w[m] if w[m] > 0 else 0
res[f's_{m}'] = math.ceil(s_esatti)
res[f'cost_{m}'] = f"{math.ceil(s_esatti)*c[m]:.2f}"
tot_s += math.ceil(s_esatti)
costo_t += math.ceil(s_esatti)*c[m]
@@ -45,46 +45,39 @@ def calcola(d):
@app.route('/', methods=['GET', 'POST'])
def index():
res = None
if request.method == 'POST': res = calcola(request.form)
return render_template('index.html', res=res, form=request.form)
msg_stampa = None
if request.method == 'POST':
res = calcola(request.form)
if 'btn_stampa_cups' in request.form:
msg_stampa = esegui_stampa_cups(request.form)
return render_template('index.html', res=res, form=request.form, msg_stampa=msg_stampa)
def esegui_stampa_cups(f):
try:
ps_content = f"""%!PS
/Helvetica-Bold findfont 16 scalefont setfont
70 750 moveto (REPORT TECNICO CALCOLO CEMENTO) show
/Helvetica findfont 11 scalefont setfont
70 720 moveto (Volume: {f.get('res_vol')} m3 | Peso: {f.get('res_peso')} Kg) show
70 690 moveto (ACQUISTI:) show
80 675 moveto (- Cemento: {f.get('res_s_cem')} sacchetti) show
80 660 moveto (- Sabbia: {f.get('res_s_sab')} sacchetti) show
80 645 moveto (- Ghiaia: {f.get('res_s_ghi')} sacchetti) show
70 620 moveto (COSTO TOTALE: {f.get('res_costo_t')} Euro) show
70 590 moveto (DOSAGGIO CARICO ({f.get('res_nc')} carichi):) show
80 575 moveto (- Cemento: {f.get('res_bc_cem')} | Sabbia: {f.get('res_bc_sab')}) show
80 560 moveto (- Ghiaia: {f.get('res_bc_ghi')} | Acqua: {f.get('res_bc_aq')} L) show
showpage"""
comando = ["docker", "exec", "-i", "cups-pdf-server", "lp", "-d", "Virtual_PDF"]
subprocess.run(comando, input=ps_content.encode('utf-8'), capture_output=True)
return "OK - PDF generato in /output!"
except Exception as e: return f"Errore: {str(e)}"
@app.route('/download', methods=['POST'])
def download():
# Costruzione del file TXT con tutti i parametri e i risultati
f = request.form
report = f"""-------------------------------------------
REPORT TECNICO CALCOLO CEMENTO
-------------------------------------------
PARAMETRI DI INPUT:
- Dimensioni: {f.get('a')} {f.get('ua')} (Alt) x {f.get('l')} {f.get('ul')} (Lar) x {f.get('p')} {f.get('up')} (Pro)
- Miscela (Parti): Cem {f.get('p_cem')} | Sab {f.get('p_sab')} | Ghi {f.get('p_ghi')}
- Peso Sacchi: Cem {f.get('w_cem')}kg | Sab {f.get('w_sab')}kg | Ghi {f.get('w_ghi')}kg
- Costo Sacchi: Cem {f.get('c_cem')}€ | Sab {f.get('c_sab')}€ | Ghi {f.get('c_ghi')}
- Attrezzatura: Betoniera da {f.get('v_bet')} L
RISULTATI GENERALI:
- Volume Totale: {f.get('res_vol')} m3
- Peso Totale: {f.get('res_peso')} Kg
- Acqua Totale: {f.get('res_aq')} L
- Totale Sacchetti da acquistare: {f.get('res_tot_s')}
- COSTO COMPLESSIVO: {f.get('res_costo_t')}
DETTAGLIO ACQUISTI:
- Cemento: {f.get('res_s_cem')} sacchetti (€ {f.get('res_c_cem')})
- Sabbia: {f.get('res_s_sab')} sacchetti (€ {f.get('res_c_sab')})
- Ghiaia: {f.get('res_s_ghi')} sacchetti (€ {f.get('res_c_ghi')})
DOSAGGIO PER SINGOLO CARICO ({f.get('res_nc')} carichi):
- Cemento: {f.get('res_bc_cem')} sacchetti
- Sabbia: {f.get('res_bc_sab')} sacchetti
- Ghiaia: {f.get('res_bc_ghi')} sacchetti
- Acqua: {f.get('res_bc_aq')} L
-------------------------------------------
Generato da Software Cemento Rev.0
-------------------------------------------"""
return Response(report, mimetype="text/plain", headers={"Content-disposition":"attachment;filename=Report_Dettagliato.txt"})
report = f"REPORT TECNICO\nVolume: {f.get('res_vol')} m3\nCosto: {f.get('res_costo_t')} EUR"
return Response(report, mimetype="text/plain", headers={"Content-disposition":"attachment;filename=Report.txt"})
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000)

View File

@@ -3,9 +3,9 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Software Cemento Rev.0</title>
<title>Software Cemento Rev.1.1</title>
<style>
:root { --mac-bg: #f2f2f7; --mac-blue: #007aff; --mac-red: #ff3b30; --mac-green: #34c759; }
:root { --mac-bg: #f2f2f7; --mac-blue: #007aff; --mac-red: #ff3b30; --mac-green: #34c759; --mac-gray: #8e8e93; }
body { font-family: -apple-system, system-ui, sans-serif; background: var(--mac-bg); padding: 20px; font-size: 14px; color: #1c1c1e; }
.container { display: flex; flex-wrap: wrap; gap: 20px; justify-content: center; max-width: 1200px; margin: auto; }
.panel { background: rgba(255,255,255,0.8); backdrop-filter: blur(10px); border-radius: 12px; padding: 20px; flex: 1; min-width: 320px; box-shadow: 0 4px 15px rgba(0,0,0,0.05); }
@@ -16,120 +16,91 @@
.h-blue { background: var(--mac-blue); }
.h-red { background: var(--mac-red); }
.input-group { position: relative; display: inline-block; width: 90%; }
input { width: 100%; border: 1px solid #d1d1d6; border-radius: 5px; padding: 6px 5px; text-align: center; font-size: 14px; box-sizing: border-box; }
.unit-label { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); color: #8e8e93; pointer-events: none; }
select { border: 1px solid #d1d1d6; border-radius: 5px; padding: 5px; font-size: 14px; }
input { width: 90%; border: 1px solid #d1d1d6; border-radius: 5px; padding: 6px; text-align: center; font-size: 14px; }
select { border: 1px solid #d1d1d6; border-radius: 5px; padding: 5px; }
.btn { width: 100%; padding: 12px; border-radius: 8px; border: none; font-weight: 600; cursor: pointer; margin-top: 10px; font-size: 15px; color: white; text-transform: uppercase; }
.btn-calc { background: var(--mac-green); }
.btn-exp { background: #5856d6; margin-top: 20px; }
.btn-exp { background: #5856d6; }
.btn-cups { background: var(--mac-blue); }
.btn-print { background: #c7c7cc; color: #1c1c1e; }
.res-section { margin-bottom: 15px; }
.res-section h4 { margin: 0 0 5px 0; text-transform: uppercase; font-size: 12px; color: #8e8e93; }
.res-box { background: white; padding: 15px; border-radius: 10px; border: 1px solid #d1d1d6; line-height: 1.6; }
.res-section h4 { margin: 10px 0 5px 0; text-transform: uppercase; font-size: 11px; color: var(--mac-gray); }
ul { list-style: none; padding: 0; margin: 0; }
li { padding-left: 15px; position: relative; margin-bottom: 2px; }
li::before { content: "•"; position: absolute; left: 0; color: #1c1c1e; }
hr { border: 0; border-top: 1px solid #d1d1d6; margin: 15px 0; }
@media print { .no-print { display: none !important; } .res-box { border: none; } }
.footer { text-align: center; font-size: 10px; color: var(--mac-gray); margin-top: 15px; text-transform: uppercase; }
@media print { .no-print { display: none !important; } }
</style>
</head>
<body>
<div class="container">
<div class="panel no-print">
<form method="POST">
<table>
<tr class="h-blue"><th colspan="3">Dimensioni</th></tr>
<tr><td>Altezza</td><td><input type="text" name="a" value="{{form.get('a','0')}}"></td><td><select name="ua">{% for u in ['m','cm','mm'] %}<option value="{{u}}" {% if form.get('ua','m')==u %}selected{% endif %}>{{u}}</option>{% endfor %}</select></td></tr>
<tr><td>Larghezza</td><td><input type="text" name="l" value="{{form.get('l','0')}}"></td><td><select name="ul">{% for u in ['m','cm','mm'] %}<option value="{{u}}" {% if form.get('ul','m')==u %}selected{% endif %}>{{u}}</option>{% endfor %}</select></td></tr>
<tr><td>Profondità</td><td><input type="text" name="p" value="{{form.get('p','0')}}"></td><td><select name="up">{% for u in ['m','cm','mm'] %}<option value="{{u}}" {% if form.get('up','m')==u %}selected{% endif %}>{{u}}</option>{% endfor %}</select></td></tr>
<table><tr class="h-blue"><th colspan="3">Dimensioni</th></tr>
<tr><td>Altezza</td><td><input type="text" name="a" value="{{form.get('a','1')}}"></td><td><select name="ua">{% for u in ['m','cm','mm'] %}<option value="{{u}}" {% if form.get('ua','m')==u %}selected{% endif %}>{{u}}</option>{% endfor %}</select></td></tr>
<tr><td>Larghezza</td><td><input type="text" name="l" value="{{form.get('l','1')}}"></td><td><select name="ul">{% for u in ['m','cm','mm'] %}<option value="{{u}}" {% if form.get('ul','m')==u %}selected{% endif %}>{{u}}</option>{% endfor %}</select></td></tr>
<tr><td>Profondità</td><td><input type="text" name="p" value="{{form.get('p','1')}}"></td><td><select name="up">{% for u in ['m','cm','mm'] %}<option value="{{u}}" {% if form.get('up','m')==u %}selected{% endif %}>{{u}}</option>{% endfor %}</select></td></tr>
</table>
<table>
<tr class="h-red"><th colspan="3">Miscela (Parti)</th></tr>
<tr>
<td>Cemento:<br><input type="text" name="p_cem" value="{{form.get('p_cem','1')}}"></td>
<td>Sabbia:<br><input type="text" name="p_sab" value="{{form.get('p_sab','3')}}"></td>
<td>Ghiaia:<br><input type="text" name="p_ghi" value="{{form.get('p_ghi','5')}}"></td>
</tr>
<table><tr class="h-red"><th colspan="3">Miscela (Parti)</th></tr>
<tr><td>Cemento:<br><input type="text" name="p_cem" value="{{form.get('p_cem','1')}}"></td><td>Sabbia:<br><input type="text" name="p_sab" value="{{form.get('p_sab','3')}}"></td><td>Ghiaia:<br><input type="text" name="p_ghi" value="{{form.get('p_ghi','5')}}"></td></tr>
</table>
<table>
<tr class="h-red"><th colspan="3">Peso sacchette (Kg)</th></tr>
<tr>
<td>Cemento:<br><div class="input-group"><input type="text" name="w_cem" value="{{form.get('w_cem','25')}}"><span class="unit-label">Kg</span></div></td>
<td>Sabbia:<br><div class="input-group"><input type="text" name="w_sab" value="{{form.get('w_sab','25')}}"><span class="unit-label">Kg</span></div></td>
<td>Ghiaia:<br><div class="input-group"><input type="text" name="w_ghi" value="{{form.get('w_ghi','25')}}"><span class="unit-label">Kg</span></div></td>
</tr>
<table><tr class="h-red"><th colspan="3">Peso sacchette (Kg)</th></tr>
<tr><td>Cem:<input type="text" name="w_cem" value="{{form.get('w_cem','25')}}"></td><td>Sab:<input type="text" name="w_sab" value="{{form.get('w_sab','25')}}"></td><td>Ghi:<input type="text" name="w_ghi" value="{{form.get('w_ghi','25')}}"></td></tr>
</table>
<table>
<tr class="h-red"><th colspan="3">Costo sacchette (€)</th></tr>
<tr>
<td>Cemento:<br><div class="input-group"><input type="text" name="c_cem" value="{{form.get('c_cem','1')}}"><span class="unit-label"></span></div></td>
<td>Sabbia:<br><div class="input-group"><input type="text" name="c_sab" value="{{form.get('c_sab','1')}}"><span class="unit-label"></span></div></td>
<td>Ghiaia:<br><div class="input-group"><input type="text" name="c_ghi" value="{{form.get('c_ghi','1')}}"><span class="unit-label"></span></div></td>
</tr>
<table><tr class="h-red"><th colspan="3">Costo sacchette (€)</th></tr>
<tr><td>Cem:<input type="text" name="c_cem" value="{{form.get('c_cem','1')}}"></td><td>Sab:<input type="text" name="c_sab" value="{{form.get('c_sab','1')}}"></td><td>Ghi:<input type="text" name="c_ghi" value="{{form.get('c_ghi','1')}}"></td></tr>
</table>
<table>
<tr class="h-red"><th>Attrezzatura</th></tr>
<tr><td>Volume Betoniera: <div class="input-group" style="width:80px;"><input type="text" name="v_bet" value="{{form.get('v_bet','160')}}"><span class="unit-label">L</span></div></td></tr>
</table>
<table><tr class="h-red"><th>Attrezzatura</th></tr><tr><td>Volume Betoniera: <input type="text" name="v_bet" value="{{form.get('v_bet','160')}}" style="width:60px;"> L</td></tr></table>
<button type="submit" class="btn btn-calc">Esegui Calcolo</button>
</form>
<div class="footer">VERSIONE SOFTWARE: REV.1 | DATA RILASCIO: 20/01/2026</div>
</div>
<div class="panel">
<h3>Risultati</h3>
{% if res %}
<div class="res-box">
<div class="res-section">
<b>Volume:</b> {{ res.vol }} m³ | <b>Peso:</b> {{ res.peso }} Kg
</div>
<b>Volume:</b> {{ res.vol }} m³ | <b>Peso:</b> {{ res.peso }} Kg
<hr>
<div class="res-section">
<h4>Acquisti</h4>
Cemento: {{ res.s_cem }} sacchetti<br>
Sabbia: {{ res.s_sab }} sacchetti<br>
Ghiaia: {{ res.s_ghi }} sacchetti<br>
Acqua: {{ res.acqua }} L<br>
<b>Totale materiale:</b> {{ res.tot_sacc }} sacchetti
</div>
<div class="res-section">
<h4>Costo stimato</h4>
<b>Costo totale: {{ res.costo_tot }} €</b>
<ul>
<li>Cemento: {{ res.s_cem }} sacchetti</li>
<li>Sabbia: {{ res.s_sab }} sacchetti</li>
<li>Ghiaia: {{ res.s_ghi }} sacchetti</li>
<li>Acqua: {{ res.acqua }} L | <b>Totale: {{ res.tot_sacc }} sacch.</b></li>
</ul>
</div>
<div class="res-section"><h4>Costo totale: <b>{{ res.costo_tot }} €</b></h4></div>
<hr>
<div class="res-section">
<h4>Per ogni carico ({{ res.n_c }} carichi):</h4>
• Cemento: {{ res.bc_cem }} sacchetti<br>
• Sabbia: {{ res.bc_sab }} sacchetti<br>
• Ghiaia: {{ res.bc_ghi }} sacchetti<br>
• Acqua: {{ res.bc_aq }} L
<ul>
<li>Cemento: {{ res.bc_cem }} sacchetti</li>
<li>Sabbia: {{ res.bc_sab }} sacchetti</li>
<li>Ghiaia: {{ res.bc_ghi }} sacchetti</li>
<li>Acqua: {{ res.bc_aq }} L</li>
</ul>
</div>
</div>
<form action="/download" method="POST" class="no-print">
<form method="POST" class="no-print">
{% for k,v in form.items() %}<input type="hidden" name="{{k}}" value="{{v}}">{% endfor %}
<input type="hidden" name="res_vol" value="{{res.vol}}"><input type="hidden" name="res_peso" value="{{res.peso}}">
<input type="hidden" name="res_aq" value="{{res.acqua}}"><input type="hidden" name="res_tot_s" value="{{res.tot_sacc}}">
<input type="hidden" name="res_costo_t" value="{{res.costo_tot}}"><input type="hidden" name="res_s_cem" value="{{res.s_cem}}">
<input type="hidden" name="res_c_cem" value="{{res.cost_cem}}"><input type="hidden" name="res_s_sab" value="{{res.s_sab}}">
<input type="hidden" name="res_c_sab" value="{{res.cost_sab}}"><input type="hidden" name="res_s_ghi" value="{{res.s_ghi}}">
<input type="hidden" name="res_c_ghi" value="{{res.cost_ghi}}"><input type="hidden" name="res_nc" value="{{res.n_c}}">
<input type="hidden" name="res_bc_cem" value="{{res.bc_cem}}"><input type="hidden" name="res_bc_sab" value="{{res.bc_sab}}">
<input type="hidden" name="res_bc_ghi" value="{{res.bc_ghi}}"><input type="hidden" name="res_bc_aq" value="{{res.bc_aq}}">
<input type="hidden" name="a" value="{{form.get('a')}}"><input type="hidden" name="ua" value="{{form.get('ua')}}">
<input type="hidden" name="l" value="{{form.get('l')}}"><input type="hidden" name="ul" value="{{form.get('ul')}}">
<input type="hidden" name="p" value="{{form.get('p')}}"><input type="hidden" name="up" value="{{form.get('up')}}">
<input type="hidden" name="p_cem" value="{{form.get('p_cem')}}"><input type="hidden" name="p_sab" value="{{form.get('p_sab')}}"><input type="hidden" name="p_ghi" value="{{form.get('p_ghi')}}">
<input type="hidden" name="w_cem" value="{{form.get('w_cem')}}"><input type="hidden" name="w_sab" value="{{form.get('w_sab')}}"><input type="hidden" name="w_ghi" value="{{form.get('w_ghi')}}">
<input type="hidden" name="c_cem" value="{{form.get('c_cem')}}"><input type="hidden" name="c_sab" value="{{form.get('c_sab')}}"><input type="hidden" name="c_ghi" value="{{form.get('c_ghi')}}">
<input type="hidden" name="v_bet" value="{{form.get('v_bet')}}">
<button type="submit" class="btn btn-exp">Esporta TXT Completo</button>
<input type="hidden" name="res_costo_t" value="{{res.costo_tot}}"><input type="hidden" name="res_nc" value="{{res.n_c}}">
<input type="hidden" name="res_s_cem" value="{{res.s_cem}}"><input type="hidden" name="res_s_sab" value="{{res.s_sab}}"><input type="hidden" name="res_s_ghi" value="{{res.s_ghi}}">
<input type="hidden" name="res_bc_cem" value="{{res.bc_cem}}"><input type="hidden" name="res_bc_sab" value="{{res.bc_sab}}"><input type="hidden" name="res_bc_ghi" value="{{res.bc_ghi}}"><input type="hidden" name="res_bc_aq" value="{{res.bc_aq}}">
<button type="submit" name="btn_stampa_cups" class="btn btn-cups">Stampa PDF (CUPS)</button>
<button type="submit" formaction="/download" class="btn btn-exp">Esporta TXT</button>
<button type="button" onclick="window.print()" class="btn btn-print">Stampa Pagina</button>
</form>
<button onclick="window.print()" class="btn no-print" style="background:#d1d1d6; color:#1c1c1e;">Stampa</button>
{% if msg_stampa %}<p style="color:var(--mac-green); font-weight:bold; text-align:center;">{{ msg_stampa }}</p>{% endif %}
{% else %}
<p style="color:#8e8e93; text-align:center;">Inserisci i dati e premi "Esegui Calcolo".</p>
<p style="text-align:center; color:var(--mac-gray);">Inserisci i dati e calcola.</p>
{% endif %}
</div>
</div>