|
|
|
|
|
from flask import Flask, render_template_string, request, send_file |
|
from fpdf import FPDF |
|
import os |
|
import tempfile |
|
from datetime import date, timedelta |
|
|
|
app = Flask(__name__) |
|
|
|
|
|
HTML_FORM = """ |
|
<!DOCTYPE html> |
|
<html> |
|
<head> |
|
<title>Orçamento de Reforma</title> |
|
<style> |
|
body { |
|
font-family: 'Segoe UI', sans-serif; |
|
background-color: #f4f6f8; |
|
margin: 0; |
|
padding: 2rem; |
|
} |
|
h2, h3 { |
|
color: #333; |
|
} |
|
form { |
|
background: #fff; |
|
padding: 2rem; |
|
border-radius: 12px; |
|
box-shadow: 0 0 12px rgba(0,0,0,0.05); |
|
max-width: 700px; |
|
margin: auto; |
|
} |
|
label { |
|
display: block; |
|
margin-top: 1rem; |
|
font-weight: bold; |
|
} |
|
input[type="text"], |
|
input[type="number"], |
|
select { |
|
width: 100%; |
|
padding: 0.5rem; |
|
margin-top: 0.3rem; |
|
border: 1px solid #ccc; |
|
border-radius: 8px; |
|
} |
|
button { |
|
background-color: #007bff; |
|
color: white; |
|
padding: 0.75rem 1.5rem; |
|
border: none; |
|
border-radius: 8px; |
|
cursor: pointer; |
|
margin-top: 1rem; |
|
margin-right: 1rem; |
|
} |
|
button:hover { |
|
background-color: #0056b3; |
|
} |
|
.checkbox-group { |
|
display: grid; |
|
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); |
|
gap: 0.5rem; |
|
margin-top: 1rem; |
|
} |
|
.checkbox-group label { |
|
font-weight: normal; |
|
} |
|
#banheiros-container h4 { |
|
margin-top: 1rem; |
|
} |
|
ul { |
|
background: #fff; |
|
max-width: 700px; |
|
margin: 2rem auto; |
|
padding: 1rem; |
|
border-radius: 12px; |
|
box-shadow: 0 0 12px rgba(0,0,0,0.05); |
|
} |
|
</style> |
|
</head> |
|
<body> |
|
<h2 style="text-align:center;">Formulário de Orçamento de Reforma</h2> |
|
<form method="post"> |
|
<label>Nome do Contratante:</label> |
|
<input type="text" name="nome_contratante" required> |
|
|
|
<label>Endereço da Obra:</label> |
|
<input type="text" name="endereco_obra" required> |
|
|
|
<label>Dimensão da obra (m²):</label> |
|
<input type="number" step="0.1" name="dimensao_obra" required> |
|
|
|
<h3>Cozinha</h3> |
|
<label>Tamanho:</label> |
|
<select name="cozinha_tamanho"> |
|
<option value="pequeno">Pequeno</option> |
|
<option value="medio">Médio</option> |
|
<option value="grande">Grande</option> |
|
</select> |
|
<label>Acabamento:</label> |
|
<select name="cozinha_acabamento"> |
|
<option value="simples">Simples</option> |
|
<option value="medio">Médio</option> |
|
<option value="luxo">Luxo</option> |
|
</select> |
|
|
|
<h3>Banheiros</h3> |
|
<label>Quantidade:</label> |
|
<input type="number" name="banheiros" min="0" max="5" value="1" required> |
|
<div id="banheiros-container"></div> |
|
|
|
<h3>Serviços</h3> |
|
<div class="checkbox-group"> |
|
<label><input type="checkbox" name="servicos" value="hidraulica"> Hidráulica</label> |
|
<label><input type="checkbox" name="servicos" value="eletrica"> Elétrica</label> |
|
<label><input type="checkbox" name="servicos" value="pintura"> Pintura</label> |
|
<label><input type="checkbox" name="servicos" value="ar_condicionado"> Ar Condicionado</label> |
|
<label><input type="checkbox" name="servicos" value="fechamento_sacada"> Fechamento de Sacada</label> |
|
<label><input type="checkbox" name="servicos" value="gesso"> Gesso</label> |
|
</div> |
|
|
|
<button type="submit" name="acao" value="Calcular Orçamento">Calcular Orçamento</button> |
|
<button type="submit" name="acao" value="Gerar Contrato PDF">Gerar Contrato PDF</button> |
|
</form> |
|
|
|
{% if total %} |
|
<ul> |
|
<h3>Resumo do Orçamento</h3> |
|
{% for item in detalhes %} |
|
<li>{{ item }}</li> |
|
{% endfor %} |
|
<p><strong>Total: R$ {{ total }}</strong></p> |
|
</ul> |
|
{% endif %} |
|
|
|
<script> |
|
function gerarBanheiros() { |
|
const container = document.getElementById("banheiros-container"); |
|
const qtd = parseInt(document.querySelector("input[name='banheiros']").value); |
|
container.innerHTML = ""; |
|
for (let i = 1; i <= qtd; i++) { |
|
container.innerHTML += ` |
|
<h4>Banheiro ${i}</h4> |
|
<label>Tamanho:</label> |
|
<select name="banheiro_${i}_tamanho"> |
|
<option value="pequeno">Pequeno</option> |
|
<option value="medio">Médio</option> |
|
<option value="grande">Grande</option> |
|
</select> |
|
<label>Acabamento:</label> |
|
<select name="banheiro_${i}_acabamento"> |
|
<option value="simples">Simples</option> |
|
<option value="medio">Médio</option> |
|
<option value="luxo">Luxo</option> |
|
</select> |
|
`; |
|
} |
|
} |
|
window.onload = gerarBanheiros; |
|
document.querySelector("input[name='banheiros']").addEventListener("input", gerarBanheiros); |
|
</script> |
|
</body> |
|
</html> |
|
""" |
|
|
|
if __name__ == "__main__": |
|
app.run(host="0.0.0.0", port=7860) |
|
|
|
|
|
|
|
|
|
|
|
|