feat: rotas e telas de CLIENTE (listar, criar, editar, detalhe, excluir)

This commit is contained in:
Gustavo
2026-08-13 10:07:15 -03:00
parent e93a0f3d1d
commit c7f2c5f92b
7 changed files with 334 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
<!-- app/templates/base.html -->
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<title>{% block titulo %}Painel de Clientes{% endblock %}</title>
<style>
body { font-family: system-ui, sans-serif; margin: 0; background: #17171a; color: #f4f4f5; }
nav { background: #232326; padding: 12px 20px; display: flex; gap: 16px; }
nav a { color: #f4f4f5; text-decoration: none; }
nav a:hover { color: #F5821F; }
main { padding: 20px; max-width: 960px; margin: 0 auto; }
table { width: 100%; border-collapse: collapse; margin-top: 12px; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid #3a3a3e; }
input, select { padding: 8px; border-radius: 6px; border: 1px solid #3a3a3e; background: #17171a; color: #f4f4f5; width: 100%; box-sizing: border-box; }
label { display: block; margin-top: 10px; font-size: 0.85rem; color: #a1a1aa; }
button { margin-top: 14px; padding: 10px 16px; border: none; border-radius: 6px; background: #F5821F; color: #17171a; font-weight: 700; cursor: pointer; }
.mensagem { padding: 10px; border-radius: 6px; margin-bottom: 12px; }
.mensagem.success { background: #14532d; }
.mensagem.danger { background: #7f1d1d; }
.mensagem.warning { background: #78350f; }
a.botao { display: inline-block; padding: 6px 10px; border: 1px solid #3a3a3e; border-radius: 6px; color: #f4f4f5; text-decoration: none; margin-right: 6px; }
</style>
</head>
<body>
<nav>
<a href="/clientes">Clientes</a>
<a href="/gerador-chave">Gerador de chave</a>
</nav>
<main>
{% if mensagem %}<div class="mensagem {{ mensagem_tipo or 'success' }}">{{ mensagem }}</div>{% endif %}
{% block conteudo %}{% endblock %}
</main>
</body>
</html>
+31
View File
@@ -0,0 +1,31 @@
<!-- app/templates/cliente_detalhe.html -->
{% extends "base.html" %}
{% block titulo %}{{ cliente.RAZAO }}{% endblock %}
{% block conteudo %}
<h1>{{ cliente.FANTASIA }} <small>({{ cliente.CODIGO }})</small></h1>
<p>{{ cliente.RAZAO }} — {{ cliente.CNPJ }}</p>
<p>
<a class="botao" href="/clientes/{{ cliente.ID }}/editar">Editar</a>
<form method="post" action="/clientes/{{ cliente.ID }}/excluir" style="display:inline">
<button type="submit" onclick="return confirm('Excluir este cliente?')">Excluir</button>
</form>
</p>
<h2>Contatos</h2>
<table>
<tr><th>Nome</th><th>Telefone</th><th>E-mail</th></tr>
{% for ct in contatos %}
<tr><td>{{ ct.NOME }}</td><td>{{ ct.TELEFONE }}</td><td>{{ ct.EMAIL or "" }}</td></tr>
{% endfor %}
</table>
<h2>Status em Clientes_Chaves</h2>
{% if status_chaves %}
<table>
<tr>{% for mes in status_chaves.meses %}<th>{{ mes }}</th>{% endfor %}</tr>
<tr>{% for mes, valor in status_chaves.meses.items() %}<td>{{ "✓" if valor else "—" }}</td>{% endfor %}</tr>
</table>
{% else %}
<p>Nenhuma linha em Clientes_Chaves para o código {{ cliente.CODIGO }}.</p>
{% endif %}
{% endblock %}
+26
View File
@@ -0,0 +1,26 @@
<!-- app/templates/cliente_form.html -->
{% extends "base.html" %}
{% block titulo %}{{ "Editar" if cliente else "Novo" }} cliente{% endblock %}
{% block conteudo %}
<h1>{{ "Editar" if cliente else "Novo" }} cliente</h1>
{% if aviso_codigo_duplicado %}
<div class="mensagem warning">
O código {{ dados.CODIGO }} já está em uso por outro cliente.
<form method="post">
{% for campo, valor in dados.items() %}<input type="hidden" name="{{ campo }}" value="{{ valor }}">{% endfor %}
<input type="hidden" name="confirmar_codigo_duplicado" value="1">
<button type="submit">Cadastrar mesmo assim</button>
</form>
</div>
{% endif %}
{% if aviso_dv_invalido %}
<div class="mensagem warning">O dígito verificador do documento ({{ dados.CNPJ }}) não confere — confirme se digitou certo antes de salvar.</div>
{% endif %}
<form method="post">
{% for campo in campos %}
<label for="{{ campo }}">{{ campo }}</label>
<input type="text" id="{{ campo }}" name="{{ campo }}" value="{{ dados[campo] if dados else '' }}">
{% endfor %}
<button type="submit">Salvar</button>
</form>
{% endblock %}
+23
View File
@@ -0,0 +1,23 @@
<!-- app/templates/clientes_lista.html -->
{% extends "base.html" %}
{% block titulo %}Clientes{% endblock %}
{% block conteudo %}
<h1>Clientes</h1>
<form method="get" action="/clientes">
<input type="text" name="busca" value="{{ busca or '' }}" placeholder="Buscar por código, CNPJ, razão ou fantasia">
<button type="submit">Buscar</button>
</form>
<p><a class="botao" href="/clientes/novo">+ Novo cliente</a></p>
<table>
<tr><th>Código</th><th>Razão</th><th>Fantasia</th><th>CNPJ</th><th></th></tr>
{% for c in clientes %}
<tr>
<td>{{ c.CODIGO }}</td>
<td>{{ c.RAZAO }}</td>
<td>{{ c.FANTASIA }}</td>
<td>{{ c.CNPJ }}</td>
<td><a class="botao" href="/clientes/{{ c.ID }}">Abrir</a></td>
</tr>
{% endfor %}
</table>
{% endblock %}