File size: 2,464 Bytes
5a638d8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import streamlit as st
from datetime import date
import locale
import os

# Corrigir locale para português (Windows)
try:
    locale.setlocale(locale.LC_TIME, "Portuguese_Brazil.1252")
except:
    pass

# Mapear os modelos HTML disponíveis
html_template_paths = {
    "Clean": "modelo_proposta_clean.html",
    "Topo Moderno": "modelo_proposta_topo_moderno.html",
    "Topo Gradiente": "modelo_proposta_topo_gradiente.html"
}

st.set_page_config(page_title="Gerador de Propostas", layout="centered")
st.title("📝 Gerador de Propostas - EasyDevBots")

# Formulário de preenchimento
nome_cliente = st.text_input("Nome do Cliente")
data_proposta = st.date_input("Data da Proposta", value=date.today()).strftime("%d de %B de %Y")
nome_projeto = st.text_input("Nome do Projeto")
objetivo = st.text_area("Objetivo da Proposta")
valor = st.text_input("Valor Total (R$)")
pagamento = st.text_input("Forma de Pagamento")
prazo_entrega = st.text_input("Prazo de Entrega")
observacoes = st.text_area("Observações / Bônus")
validade_proposta = st.text_input("Validade da Proposta", value="15 dias")

# Escolher layout visual
modelo = st.selectbox("Escolha o modelo visual da proposta:", ["Clean", "Topo Moderno", "Topo Gradiente"])

# Botão de geração
if st.button("📄 Gerar Proposta"):
    modelo_path = html_template_paths[modelo]
    
    if not os.path.exists(modelo_path):
        st.error(f"Modelo HTML não encontrado: {modelo_path}")
    else:
        # Ler modelo e substituir campos
        with open(modelo_path, "r", encoding="utf-8") as f:
            html = f.read()
        contexto = {
            "{{nome_cliente}}": nome_cliente,
            "{{data_proposta}}": data_proposta,
            "{{nome_projeto}}": nome_projeto,
            "{{objetivo}}": objetivo,
            "{{valor}}": valor,
            "{{pagamento}}": pagamento,
            "{{prazo_entrega}}": prazo_entrega,
            "{{observacoes}}": observacoes,
            "{{validade_proposta}}": validade_proposta
        }
        for chave, valor in contexto.items():
            html = html.replace(chave, valor)
        
        nome_arquivo = f"Proposta_{nome_cliente.replace(' ', '_')}.html"
        with open(nome_arquivo, "w", encoding="utf-8") as f:
            f.write(html)

        st.success("✅ Proposta gerada com sucesso!")
        with open(nome_arquivo, "rb") as file:
            st.download_button("📥 Baixar Proposta HTML", file, file_name=nome_arquivo)