Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2749446249 | |||
| 71ce30307b | |||
| 242412dc19 | |||
| c8c4496d4a | |||
| 8a92767293 | |||
| 27aded61fd | |||
| 3e11847964 | |||
| d4596b2eeb | |||
| 9eae600e81 | |||
| 10c13225cc | |||
| adae2623e6 | |||
| df94568376 | |||
| 1be5e787a3 | |||
| 14902379d8 | |||
| 1ac313efa7 | |||
| 002da8f77f | |||
| bd7b1d2533 |
19
cemento.py
19
cemento.py
@@ -1,9 +1,19 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import sys
|
||||
import os
|
||||
|
||||
# 1. PERCORSO LIBRERIE SPECIFICO PER SYNOLOGY (Identificato con il test)
|
||||
# Questo permette a Gitea di trovare Flask anche se l'utente è diverso
|
||||
sys.path.append('/var/services/homes/Francesco/.local/lib/python3.8/site-packages')
|
||||
|
||||
from flask import Flask, render_template, request, Response
|
||||
import math
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
# 2. DEFINIZIONE VERSIONE (Apparirà in rosso sul sito)
|
||||
VERSIONE = "Rev.1"
|
||||
|
||||
def calcola(d):
|
||||
try:
|
||||
def to_m(v, u):
|
||||
@@ -46,14 +56,14 @@ def calcola(d):
|
||||
def index():
|
||||
res = None
|
||||
if request.method == 'POST': res = calcola(request.form)
|
||||
return render_template('index.html', res=res, form=request.form)
|
||||
# Passiamo la revisione al template HTML
|
||||
return render_template('index.html', res=res, form=request.form, rev=VERSIONE)
|
||||
|
||||
@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
|
||||
REPORT TECNICO CALCOLO CEMENTO
|
||||
-------------------------------------------
|
||||
|
||||
PARAMETRI DI INPUT:
|
||||
@@ -82,9 +92,10 @@ DOSAGGIO PER SINGOLO CARICO ({f.get('res_nc')} carichi):
|
||||
- Acqua: {f.get('res_bc_aq')} L
|
||||
|
||||
-------------------------------------------
|
||||
Generato da Software Cemento Rev.0
|
||||
Generato da Software Cemento {VERSIONE}
|
||||
-------------------------------------------"""
|
||||
return Response(report, mimetype="text/plain", headers={"Content-disposition":"attachment;filename=Report_Dettagliato.txt"})
|
||||
|
||||
if __name__ == '__main__':
|
||||
# Avvio del server sulla porta 5000
|
||||
app.run(host='0.0.0.0', port=5000)
|
||||
@@ -3,34 +3,134 @@
|
||||
<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 if rev else 'Rev.11.0' }}</title>
|
||||
<style>
|
||||
:root { --mac-bg: #f2f2f7; --mac-blue: #007aff; --mac-red: #ff3b30; --mac-green: #34c759; }
|
||||
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); }
|
||||
:root {
|
||||
--mac-bg: #f2f2f7;
|
||||
--mac-blue: #007aff;
|
||||
--mac-red: #ff3b30;
|
||||
--mac-green: #34c759;
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
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; }
|
||||
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;
|
||||
}
|
||||
.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-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;
|
||||
font-size: 11px;
|
||||
}
|
||||
select {
|
||||
border: 1px solid #d1d1d6;
|
||||
border-radius: 5px;
|
||||
padding: 5px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.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 {
|
||||
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; }
|
||||
|
||||
.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: 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;
|
||||
}
|
||||
/* CLASSE AGGIORNATA IN ROSSO */
|
||||
.rev-tag {
|
||||
font-size: 11px;
|
||||
color: var(--mac-red);
|
||||
font-weight: bold;
|
||||
text-align: right;
|
||||
}
|
||||
hr { border: 0; border-top: 1px solid #d1d1d6; margin: 15px 0; }
|
||||
|
||||
@media print { .no-print { display: none !important; } .res-box { border: none; } }
|
||||
@media print {
|
||||
.no-print { display: none !important; }
|
||||
.res-box { border: none; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -38,10 +138,40 @@
|
||||
<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>
|
||||
<tr class="h-blue"><th colspan="3">Dimensioni Totali</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>
|
||||
|
||||
<table>
|
||||
@@ -54,7 +184,7 @@
|
||||
</table>
|
||||
|
||||
<table>
|
||||
<tr class="h-red"><th colspan="3">Peso sacchette (Kg)</th></tr>
|
||||
<tr class="h-red"><th colspan="3">Peso sacchetti (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>
|
||||
@@ -63,7 +193,7 @@
|
||||
</table>
|
||||
|
||||
<table>
|
||||
<tr class="h-red"><th colspan="3">Costo sacchette (€)</th></tr>
|
||||
<tr class="h-red"><th colspan="3">Costo sacchetti (€)</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>
|
||||
@@ -73,7 +203,9 @@
|
||||
|
||||
<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>
|
||||
<tr>
|
||||
<td>Volume utile 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>
|
||||
|
||||
<button type="submit" class="btn btn-calc">Esegui Calcolo</button>
|
||||
@@ -81,15 +213,19 @@
|
||||
</div>
|
||||
|
||||
<div class="panel">
|
||||
<h3>Risultati</h3>
|
||||
<div style="display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px;">
|
||||
<h3 style="margin: 0;">Risultati</h3>
|
||||
<span class="rev-tag">{{ rev if rev else 'Rev.1.0' }}</span>
|
||||
</div>
|
||||
|
||||
{% if res %}
|
||||
<div class="res-box">
|
||||
<div class="res-section">
|
||||
<b>Volume:</b> {{ res.vol }} m³ | <b>Peso:</b> {{ res.peso }} Kg
|
||||
<b>Volume Totale:</b> {{ res.vol }} m³ | <b>Peso Stimato:</b> {{ res.peso }} Kg
|
||||
</div>
|
||||
<hr>
|
||||
<div class="res-section">
|
||||
<h4>Acquisti</h4>
|
||||
<h4>Acquisti Necessari</h4>
|
||||
Cemento: {{ res.s_cem }} sacchetti<br>
|
||||
Sabbia: {{ res.s_sab }} sacchetti<br>
|
||||
Ghiaia: {{ res.s_ghi }} sacchetti<br>
|
||||
@@ -98,17 +234,20 @@
|
||||
</div>
|
||||
<div class="res-section">
|
||||
<h4>Costo stimato</h4>
|
||||
<b>Costo totale: {{ res.costo_tot }} €</b>
|
||||
<b style="font-size: 16px; color: var(--mac-blue);">Costo totale: {{ res.costo_tot }} €</b>
|
||||
</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
|
||||
<h4>Dosaggio per ogni carico ({{ res.n_c }} carichi):</h4>
|
||||
<div style="background: #f9f9f9; padding: 10px; border-radius: 5px; margin-top: 5px;">
|
||||
• Cemento: <b>{{ res.bc_cem }}</b> sacchetti<br>
|
||||
• Sabbia: <b>{{ res.bc_sab }}</b> sacchetti<br>
|
||||
• Ghiaia: <b>{{ res.bc_ghi }}</b> sacchetti<br>
|
||||
• Acqua: <b>{{ res.bc_aq }}</b> L
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form action="/download" method="POST" class="no-print">
|
||||
<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}}">
|
||||
@@ -125,11 +264,11 @@
|
||||
<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>
|
||||
<button type="submit" class="btn btn-exp">Esporta Report TXT</button>
|
||||
</form>
|
||||
<button onclick="window.print()" class="btn no-print" style="background:#d1d1d6; color:#1c1c1e;">Stampa</button>
|
||||
<button onclick="window.print()" class="btn no-print" style="background:#d1d1d6; color:#1c1c1e;">Stampa Risultati</button>
|
||||
{% else %}
|
||||
<p style="color:#8e8e93; text-align:center;">Inserisci i dati e premi "Esegui Calcolo".</p>
|
||||
<p style="color:#8e8e93; text-align:center; margin-top: 40px;">Inserisci i dati dimensionali e i costi, poi premi <b>"Esegui Calcolo"</b>.</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user