6 Commits
v1.2 ... v1.3

Author SHA1 Message Date
c04fa96ab2 Update templates/index.html 2026-01-20 15:17:20 +01:00
cdcfdba82e Update cemento.py 2026-01-20 15:16:50 +01:00
6433e722e2 Update templates/index.html 2026-01-20 15:12:06 +01:00
c9f359b30d Update cemento.py 2026-01-20 15:11:40 +01:00
5599c9fd14 Update templates/index.html 2026-01-20 15:02:05 +01:00
34dec1e646 Update cemento.py 2026-01-20 15:01:37 +01:00
2 changed files with 99 additions and 68 deletions

View File

@@ -11,7 +11,10 @@ def calcola(d):
val = float(v.replace(',', '.')) if v else 0
return val / 1000 if u == "mm" else val / 100 if u == "cm" else val
vol = to_m(d.get('a','0'), d.get('ua','m')) * to_m(d.get('l','0'), d.get('ul','m')) * to_m(d.get('p','0'), d.get('up','m'))
# Salvo le dimensioni originali per il report
dim_orig = {"a": d.get('a','0'), "ua": d.get('ua','m'), "l": d.get('l','0'), "ul": d.get('ul','m'), "p": d.get('p','0'), "up": d.get('up','m')}
vol = to_m(dim_orig['a'], dim_orig['ua']) * to_m(dim_orig['l'], dim_orig['ul']) * to_m(dim_orig['p'], dim_orig['up'])
peso_tot = vol * 2400
mats = ['cem', 'sab', 'ghi']
@@ -20,7 +23,9 @@ def calcola(d):
c = {m: float(d.get(f'c_{m}', '0').replace(',','.')) for m in mats}
somma_p = sum(p.values())
res = {"vol": f"{vol:.3f}", "peso": f"{peso_tot:.0f}"}
perc = {m: (p[m]/somma_p)*100 if somma_p > 0 else 0 for m in mats}
res = {"vol": f"{vol:.3f}", "peso": f"{peso_tot:.0f}", "perc": perc, "dim": dim_orig, "parti": p}
tot_s, costo_t = 0, 0
for m in mats:
@@ -55,29 +60,56 @@ def index():
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
/Helvetica-Bold findfont 11 scalefont setfont
70 760 moveto (DIMENSIONI GETTO) show
/Helvetica findfont 10 scalefont setfont
70 745 moveto (Altezza: {f.get('d_a')} {f.get('d_ua')} | Larghezza: {f.get('d_l')} {f.get('d_ul')} | Profondita: {f.get('d_p')} {f.get('d_up')}) show
/Helvetica-Bold findfont 11 scalefont setfont
70 720 moveto (VOLUME: {f.get('res_vol')} m3 | Peso: {f.get('res_peso')} Kg) show
70 700 moveto (ACQUISTI) show
/Helvetica findfont 10 scalefont setfont
70 685 moveto (o Cemento: {f.get('res_s_cem')} sacchetti) show
70 670 moveto (o Sabbia: {f.get('res_s_sab')} sacchetti) show
70 655 moveto (o Ghiaia: {f.get('res_s_ghi')} sacchetti) show
70 640 moveto (o Acqua: {f.get('res_aq')} L | Totale: {f.get('res_tot_s')} sacch.) show
/Helvetica-Bold findfont 11 scalefont setfont
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
70 600 moveto (PROPORZIONI) show
/Helvetica findfont 10 scalefont setfont
70 585 moveto (Cem: {f.get('p_cem')} ({f.get('pc_cem')}%) | Sab: {f.get('p_sab')} ({f.get('pc_sab')}%) | Ghi: {f.get('p_ghi')} ({f.get('pc_ghi')}%)) show
70 560 moveto (PER OGNI CARICO ({f.get('res_nc')} CARICHI):) show
70 545 moveto (o Cemento: {f.get('res_bc_cem')} sacchetti) show
70 530 moveto (o Sabbia: {f.get('res_bc_sab')} sacchetti) show
70 515 moveto (o Ghiaia: {f.get('res_bc_ghi')} sacchetti) show
70 500 moveto (o 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)
subprocess.run(["docker", "exec", "-i", "cups-pdf-server", "lp", "-d", "Virtual_PDF"], input=ps_content.encode('utf-8'))
return "OK - PDF generato in /output!"
except Exception as e: return f"Errore: {str(e)}"
except: return "Errore di stampa"
@app.route('/download', methods=['POST'])
def download():
f = request.form
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"})
report = (
f"DIMENSIONI GETTO\n"
f"Altezza: {f.get('d_a')} {f.get('d_ua')} Larghezza: {f.get('d_l')} {f.get('d_ul')} Profondità: {f.get('d_p')} {f.get('d_up')}\n\n"
f"VOLUME: {f.get('res_vol')} m3 | Peso: {f.get('res_peso')} Kg\n\n"
f"ACQUISTI\n"
f"• Cemento: \t{f.get('res_s_cem')} sacchetti\n"
f"• Sabbia: \t{f.get('res_s_sab')} sacchetti\n"
f"• Ghiaia: \t{f.get('res_s_ghi')} sacchetti\n"
f"• Acqua: \t{f.get('res_aq')} L | Totale: {f.get('res_tot_s')} sacch.\n\n"
f"COSTO TOTALE: \t{f.get('res_costo_t')}\n\n"
f"PROPORZIONI\n"
f"Cemento: {f.get('p_cem')} \tSabbia: {f.get('p_sab')} \tGhiaia: {f.get('p_ghi')}\n"
f"Cemento: {f.get('pc_cem')}% \tSabbia: {f.get('pc_sab')}% \tGhiaia: {f.get('pc_ghi')}%\n\n"
f"PER OGNI CARICO ({f.get('res_nc')} CARICHI):\n\n"
f"• Cemento: \t{f.get('res_bc_cem')} sacchetti\n"
f"• Sabbia: \t{f.get('res_bc_sab')} sacchetti\n"
f"• Ghiaia: \t{f.get('res_bc_ghi')} sacchetti\n"
f"• Acqua: \t{f.get('res_bc_aq')} L"
)
return Response(report, mimetype="text/plain", headers={"Content-disposition":"attachment;filename=Report_V1_2.txt"})
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000)

View File

@@ -2,37 +2,29 @@
<html lang="it">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Software Cemento Rev.1.1</title>
<title>Software Cemento V 1.2</title>
<style>
: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; }
body { font-family: -apple-system, sans-serif; background: var(--mac-bg); padding: 20px; font-size: 14px; }
.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); }
table { width: 100%; border-collapse: collapse; margin-bottom: 15px; background: white; border-radius: 8px; overflow: hidden; }
th { padding: 10px; font-size: 14px; color: white; text-transform: uppercase; }
td { padding: 8px; text-align: center; border: 1px solid #e5e5ea; font-size: 14px; }
.panel { background: rgba(255,255,255,0.9); border-radius: 12px; padding: 20px; flex: 1; min-width: 320px; box-shadow: 0 4px 15px rgba(0,0,0,0.05); }
table { width: 100%; border-collapse: collapse; margin-bottom: 15px; border-radius: 8px; overflow: hidden; background: white; }
th { padding: 10px; font-size: 13px; color: white; text-transform: uppercase; }
td { padding: 8px; border: 1px solid #e5e5ea; text-align: center; }
.h-blue { background: var(--mac-blue); }
.h-red { background: var(--mac-red); }
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; }
input { width: 85%; border: 1px solid #d1d1d6; border-radius: 5px; padding: 4px; text-align: center; }
.btn { width: 100%; padding: 12px; border-radius: 8px; border: none; font-weight: bold; cursor: pointer; margin-top: 10px; color: white; text-transform: uppercase; }
.btn-calc { background: var(--mac-green); }
.btn-exp { background: #5856d6; }
.btn-cups { background: var(--mac-blue); }
.btn-print { background: #c7c7cc; color: #1c1c1e; }
.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); }
.btn-exp { background: #5856d6; }
.btn-device { background: #c7c7cc; color: #1c1c1e; }
.res-box { border: 1px solid #d1d1d6; border-radius: 10px; padding: 15px; background: #fff; line-height: 1.6; }
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; }
li { padding-left: 15px; position: relative; }
li::before { content: "•"; position: absolute; left: 0; }
hr { border: 0; border-top: 1px solid #d1d1d6; margin: 15px 0; }
.footer { text-align: center; font-size: 10px; color: var(--mac-gray); margin-top: 15px; text-transform: uppercase; }
.footer { text-align: center; font-size: 10px; color: var(--mac-gray); margin-top: 15px; }
@media print { .no-print { display: none !important; } }
</style>
</head>
@@ -41,12 +33,12 @@
<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','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>
<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>
<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>
<tr><td>Cem:<br><input type="text" name="p_cem" value="{{form.get('p_cem','1')}}"></td><td>Sab:<br><input type="text" name="p_sab" value="{{form.get('p_sab','3')}}"></td><td>Ghi:<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>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>
@@ -57,50 +49,57 @@
<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 class="footer">VERSIONE SOFTWARE: V 1.2 | DATA: 20/01/2026</div>
</div>
<div class="panel">
<h3>Risultati</h3>
{% if res %}
<div class="res-box">
<b>Volume:</b> {{ res.vol }} m³ | <b>Peso:</b> {{ res.peso }} Kg
<b>DIMENSIONI GETTO</b><br>
Altezza: {{res.dim.a}} {{res.dim.ua}} &nbsp; Larghezza: {{res.dim.l}} {{res.dim.ul}} &nbsp; Profondità: {{res.dim.p}} {{res.dim.up}}<br><br>
<b>VOLUME:</b> {{ res.vol }} m³ | <b>Peso:</b> {{ res.peso }} Kg
<hr>
<div class="res-section">
<h4>Acquisti</h4>
<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>
<b>ACQUISTI</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>
<br>
<b>COSTO TOTALE: {{ res.costo_tot }} €</b>
<hr>
<div class="res-section">
<h4>Per ogni carico ({{ res.n_c }} carichi):</h4>
<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>
<b>PROPORZIONI</b><br>
Cemento: {{res.parti.cem}} &nbsp; Sabbia: {{res.parti.sab}} &nbsp; Ghiaia: {{res.parti.ghi}}<br>
Cemento: {{ "%.1f"|format(res.perc.cem) }}% &nbsp; Sabbia: {{ "%.1f"|format(res.perc.sab) }}% &nbsp; Ghiaia: {{ "%.1f"|format(res.perc.ghi) }}%
<hr>
<b>PER OGNI CARICO ({{ res.n_c }} CARICHI):</b>
<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>
<form method="POST" class="no-print">
{% for k,v in form.items() %}<input type="hidden" name="{{k}}" value="{{v}}">{% endfor %}
<input type="hidden" name="d_a" value="{{res.dim.a}}"><input type="hidden" name="d_ua" value="{{res.dim.ua}}">
<input type="hidden" name="d_l" value="{{res.dim.l}}"><input type="hidden" name="d_ul" value="{{res.dim.ul}}">
<input type="hidden" name="d_p" value="{{res.dim.p}}"><input type="hidden" name="d_up" value="{{res.dim.up}}">
<input type="hidden" name="p_cem" value="{{res.parti.cem}}"><input type="hidden" name="p_sab" value="{{res.parti.sab}}"><input type="hidden" name="p_ghi" value="{{res.parti.ghi}}">
<input type="hidden" name="pc_cem" value="{{'%.1f'|format(res.perc.cem)}}"><input type="hidden" name="pc_sab" value="{{'%.1f'|format(res.perc.sab)}}"><input type="hidden" name="pc_ghi" value="{{'%.1f'|format(res.perc.ghi)}}">
<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_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>
<button type="button" onclick="window.print()" class="btn btn-device">Stampa Pagina</button>
</form>
{% if msg_stampa %}<p style="color:var(--mac-green); font-weight:bold; text-align:center;">{{ msg_stampa }}</p>{% endif %}
{% else %}
<p style="text-align:center; color:var(--mac-gray);">Inserisci i dati e calcola.</p>
{% endif %}
</div>
</div>