Criação da visão geral da consolidação por motorista e Estilização
This commit is contained in:
38
app/views/consolidacoes/_lista.html.erb
Normal file
38
app/views/consolidacoes/_lista.html.erb
Normal file
@@ -0,0 +1,38 @@
|
||||
<%# app/views/consolidacoes/_lista.html.erb — visão por CONSOLIDAÇÃO %>
|
||||
<% if @consolidacoes.any? %>
|
||||
<div class="space-y-3">
|
||||
<% @consolidacoes.each do |c| %>
|
||||
<%= link_to consolidacao_path(c),
|
||||
class: 'block bg-[#1a1a1a] border border-[#2a2a2a] hover:border-orange-500 rounded-xl p-5 transition-colors' do %>
|
||||
<div class="flex flex-col md:flex-row md:items-center md:justify-between gap-3">
|
||||
<div>
|
||||
<div class="flex items-center gap-3 mb-1">
|
||||
<h3 class="text-white font-bold text-lg"><%= c.nome %></h3>
|
||||
<%= badge_status(c.status) %>
|
||||
<% if c.finalizada? %><%= badge_pagamento(c.status_pagamento) %><% end %>
|
||||
</div>
|
||||
<p class="text-gray-400 text-sm">
|
||||
<%= icone :calendario %> <%= l c.data_inicio, format: :short %> → <%= l c.data_fim, format: :short %>
|
||||
· <%= icone :pessoa %> <%= c.consolidacao_motoristas.count %> motorista(s)
|
||||
· Criada por <%= c.criador.nome_display %>
|
||||
</p>
|
||||
<% if c.operacoes.present? %>
|
||||
<p class="text-gray-500 text-xs mt-1"><%= icone :pasta %> <%= c.operacoes_label.join(' · ') %></p>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="text-right">
|
||||
<p class="text-orange-500 font-black text-2xl"><%= moeda(c.valor_total) %></p>
|
||||
<p class="text-gray-500 text-xs"><%= c.consolidacao_entregas.count %> entregas classificadas</p>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% else %>
|
||||
<div class="bg-[#1a1a1a] border border-[#2a2a2a] rounded-xl p-12 text-center">
|
||||
<p class="mb-4"><%= icone :vazio, tamanho: 'w-12 h-12', cor: 'text-gray-600', espaco: false %></p>
|
||||
<p class="text-gray-400 mb-4">Nenhuma consolidação encontrada.</p>
|
||||
<%= link_to 'Criar primeira consolidação', new_consolidacao_path,
|
||||
class: 'inline-block bg-orange-500 hover:bg-orange-600 text-black font-bold px-5 py-3 rounded-lg' %>
|
||||
</div>
|
||||
<% end %>
|
||||
128
app/views/consolidacoes/_por_motorista.html.erb
Normal file
128
app/views/consolidacoes/_por_motorista.html.erb
Normal file
@@ -0,0 +1,128 @@
|
||||
<%# app/views/consolidacoes/_por_motorista.html.erb — visão por MOTORISTA
|
||||
Mesmo recorte da lista, somado por quem recebe. Clicar num motorista abre,
|
||||
ali mesmo (sem sair da tela), as consolidações que compõem o valor dele. %>
|
||||
|
||||
<%# Link desta mesma tela preservando filtros — usado pelas linhas e pelos PDFs. %>
|
||||
<% ctx = { nome: params[:nome], motorista: params[:motorista], status: params[:status],
|
||||
inicio: @inicio.strftime('%Y-%m-%d'), fim: @fim.strftime('%Y-%m-%d'),
|
||||
visao: 'motoristas' }.compact_blank %>
|
||||
|
||||
<%# ── Resumo do período ────────────────────────────────── %>
|
||||
<div class="grid grid-cols-2 xl:grid-cols-4 gap-3 mb-5">
|
||||
<div class="bg-[#1a1a1a] border border-[#2a2a2a] rounded-xl p-4">
|
||||
<p class="text-gray-400 text-xs uppercase tracking-wide"><%= icone :dinheiro %> Total do período</p>
|
||||
<p class="text-orange-500 font-black text-2xl sm:text-3xl mt-1 whitespace-nowrap"><%= moeda(@totais.total_geral) %></p>
|
||||
<p class="text-gray-500 text-xs mt-1"><%= @totais.total_consolidacoes %> consolidação(ões) · <%= @totais.linhas.size %> motorista(s)</p>
|
||||
</div>
|
||||
<div class="bg-[#1a1a1a] border border-[#2a2a2a] rounded-xl p-4">
|
||||
<p class="text-gray-400 text-xs uppercase tracking-wide"><%= icone :sucesso, cor: 'text-green-400' %> Pago</p>
|
||||
<p class="text-green-400 font-black text-2xl sm:text-3xl mt-1 whitespace-nowrap"><%= moeda(@totais.total_pago) %></p>
|
||||
</div>
|
||||
<div class="bg-[#1a1a1a] border border-[#2a2a2a] rounded-xl p-4">
|
||||
<p class="text-gray-400 text-xs uppercase tracking-wide"><%= icone :parcial, cor: 'text-amber-400' %> A pagar</p>
|
||||
<p class="text-amber-400 font-black text-2xl sm:text-3xl mt-1 whitespace-nowrap"><%= moeda(@totais.total_pendente) %></p>
|
||||
</div>
|
||||
<div class="bg-[#1a1a1a] border border-[#2a2a2a] rounded-xl p-4 flex flex-col justify-between">
|
||||
<p class="text-gray-400 text-xs uppercase tracking-wide"><%= icone :documento %> Relatório</p>
|
||||
<div class="flex flex-col gap-1.5 mt-2">
|
||||
<%= link_to rotulo(:baixar, 'PDF completo', cor: nil),
|
||||
totais_pdf_consolidacoes_path(ctx.except(:visao)),
|
||||
data: { turbo: false },
|
||||
class: 'bg-orange-500 hover:bg-orange-600 text-black font-bold text-sm px-3 py-2 rounded-lg flex items-center justify-center' %>
|
||||
<%= link_to 'Só o resumo',
|
||||
totais_pdf_consolidacoes_path(ctx.except(:visao).merge(detalhar: '0')),
|
||||
data: { turbo: false },
|
||||
class: 'text-gray-400 hover:text-orange-500 text-xs underline text-center' %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% if @totais.vazio? %>
|
||||
<div class="bg-[#1a1a1a] border border-[#2a2a2a] rounded-xl p-12 text-center">
|
||||
<p class="mb-4"><%= icone :vazio, tamanho: 'w-12 h-12', cor: 'text-gray-600', espaco: false %></p>
|
||||
<p class="text-gray-400">Nenhuma consolidação com período dentro de <%= l @inicio, format: :short %> → <%= l @fim, format: :short %>.</p>
|
||||
<p class="text-gray-500 text-sm mt-1">Ajuste as datas acima — o recorte pega a consolidação inteira dentro da faixa.</p>
|
||||
</div>
|
||||
<% else %>
|
||||
<div class="space-y-3">
|
||||
<% @totais.linhas.each do |linha| %>
|
||||
<% aberto = @detalhe_motorista == linha[:motorista] %>
|
||||
<div class="bg-[#1a1a1a] border rounded-xl overflow-hidden transition-colors <%= aberto ? 'border-orange-500' : 'border-[#2a2a2a] hover:border-orange-500/60' %>">
|
||||
|
||||
<%# Cabeçalho do motorista — o clique abre/fecha a composição %>
|
||||
<%= link_to consolidacoes_path(ctx.merge(detalhe: (aberto ? nil : linha[:motorista])).compact_blank),
|
||||
class: 'block p-5' do %>
|
||||
<div class="flex flex-col md:flex-row md:items-center md:justify-between gap-3">
|
||||
<div class="min-w-0">
|
||||
<div class="flex items-center gap-2">
|
||||
<%= icone(aberto ? :expandir : :avancar, cor: 'text-gray-500', espaco: false) %>
|
||||
<h3 class="text-white font-bold text-lg truncate"><%= linha[:motorista] %></h3>
|
||||
</div>
|
||||
<p class="text-gray-400 text-sm mt-1 ml-6">
|
||||
<%= icone :consolidacoes %> <%= linha[:consolidacoes] %> consolidação(ões)
|
||||
· <%= icone :caminhao %> <%= linha[:lancamentos] %> lançamentos
|
||||
<% if linha[:pagas].positive? %>· <span class="text-green-400"><%= linha[:pagas] %> paga(s)</span><% end %>
|
||||
<% if linha[:pendentes].positive? %>· <span class="text-amber-400"><%= linha[:pendentes] %> a pagar</span><% end %>
|
||||
</p>
|
||||
</div>
|
||||
<div class="text-right shrink-0">
|
||||
<p class="text-orange-500 font-black text-2xl whitespace-nowrap"><%= moeda(linha[:valor_total]) %></p>
|
||||
<p class="text-xs mt-0.5 whitespace-nowrap">
|
||||
<span class="text-green-400"><%= moeda(linha[:valor_pago]) %> pago</span>
|
||||
<span class="text-gray-600">·</span>
|
||||
<span class="text-amber-400"><%= moeda(linha[:valor_pendente]) %> a pagar</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%# Composição — o que forma o valor daquele motorista %>
|
||||
<% if aberto %>
|
||||
<div class="border-t border-[#2a2a2a] bg-[#0f0f0f] p-5">
|
||||
<div class="flex flex-wrap items-center justify-between gap-2 mb-3">
|
||||
<p class="text-gray-300 text-sm font-semibold flex items-center gap-2">
|
||||
<%= icone :composicao, espaco: false %> O que forma esse valor
|
||||
</p>
|
||||
<%= link_to rotulo(:baixar, 'PDF deste motorista', cor: nil),
|
||||
totais_pdf_consolidacoes_path(ctx.except(:visao).merge(detalhe: linha[:motorista])),
|
||||
data: { turbo: false },
|
||||
class: 'text-gray-300 hover:text-orange-500 text-xs border border-[#2a2a2a] hover:border-orange-500 rounded-lg px-3 py-2 flex items-center' %>
|
||||
</div>
|
||||
|
||||
<div class="space-y-2">
|
||||
<% @detalhe.each do |cm| %>
|
||||
<% c = cm.consolidacao %>
|
||||
<%= link_to consolidacao_path(c),
|
||||
class: 'flex flex-col md:flex-row md:items-center md:justify-between gap-2 bg-[#1a1a1a] border border-[#2a2a2a] hover:border-orange-500 rounded-lg px-4 py-3 transition-colors' do %>
|
||||
<div class="min-w-0">
|
||||
<div class="flex items-center gap-2 flex-wrap">
|
||||
<span class="text-white font-semibold truncate"><%= c.nome %></span>
|
||||
<%= badge_status(c.status) %>
|
||||
<%= badge_pagamento(cm.pago? ? :pago : :pendente) %>
|
||||
</div>
|
||||
<p class="text-gray-400 text-xs mt-1">
|
||||
<%= icone :calendario %> <%= l c.data_inicio, format: :short %> → <%= l c.data_fim, format: :short %>
|
||||
<% if cm.pago? %>
|
||||
· <%= icone :dinheiro, cor: 'text-green-400' %> Pago em <%= l cm.pago_em.to_date, format: :short %>
|
||||
<% if cm.forma_pagamento.present? %>via <%= cm.forma_pagamento.humanize %><% end %>
|
||||
<% if cm.nota_fiscal.present? %>· NF <%= cm.nota_fiscal %><% end %>
|
||||
<% end %>
|
||||
</p>
|
||||
</div>
|
||||
<p class="text-orange-500 font-black text-lg whitespace-nowrap"><%= moeda(cm.valor_total) %></p>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<p class="text-gray-500 text-xs mt-4">
|
||||
<%= icone :dica %> Entram as consolidações
|
||||
<%= params[:status].presence ? "com status #{params[:status]}" : 'de qualquer status' %>
|
||||
cujo período está dentro de <%= l @inicio, format: :short %> → <%= l @fim, format: :short %>.
|
||||
Motoristas arquivados na consolidação não entram no total.
|
||||
</p>
|
||||
<% end %>
|
||||
@@ -6,8 +6,6 @@
|
||||
<div class="flex items-center justify-between mb-6">
|
||||
<h1 class="text-2xl font-bold text-white flex items-center gap-2"><%= icone :consolidacoes, espaco: false %> Consolidações</h1>
|
||||
<div class="flex gap-2">
|
||||
<%= link_to rotulo(:motorista, 'Totais por motorista', cor: nil), totais_consolidacoes_path,
|
||||
class: 'text-gray-400 hover:text-white border border-[#2a2a2a] px-4 py-3 rounded-lg min-h-[48px] flex items-center transition-colors' %>
|
||||
<%= link_to rotulo(:arquivadas, 'Arquivadas', cor: nil), arquivadas_consolidacoes_path,
|
||||
class: 'text-gray-400 hover:text-white border border-[#2a2a2a] px-4 py-3 rounded-lg min-h-[48px] flex items-center transition-colors' %>
|
||||
<% if policy(Consolidacao).create? %>
|
||||
@@ -72,6 +70,25 @@
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<%# ── Modo de visualização ──────────────────────────────
|
||||
A mesma tela lida de dois jeitos: por CONSOLIDAÇÃO (como o trabalho é
|
||||
organizado) e por MOTORISTA (como o pagamento sai). Os filtros abaixo valem
|
||||
para os dois — por isso eles viajam junto no link da aba. %>
|
||||
<% ctx_filtros = { nome: params[:nome], motorista: params[:motorista], status: params[:status],
|
||||
pagamento: params[:pagamento], vehicle: params[:vehicle],
|
||||
inicio: params[:inicio], fim: params[:fim] }.compact_blank %>
|
||||
<div class="flex flex-wrap items-center gap-2 border-b border-[#2a2a2a] pb-3 mb-5">
|
||||
<% [['lista', :consolidacoes, 'Consolidações'], ['motoristas', :motorista, 'Por motorista']].each do |modo, ic, label| %>
|
||||
<% ativo = @visao == modo %>
|
||||
<%= link_to rotulo(ic, label, cor: (ativo ? nil : 'text-brand-laranja')),
|
||||
consolidacoes_path(ctx_filtros.merge(visao: modo)),
|
||||
class: "px-4 py-2.5 rounded-xl text-sm font-semibold whitespace-nowrap #{ativo ? 'bg-orange-500 text-black' : 'bg-[#1a1a1a] text-gray-300 border border-[#2a2a2a] hover:border-orange-500'}" %>
|
||||
<% end %>
|
||||
<span class="text-gray-500 text-xs ml-auto hidden sm:block">
|
||||
<%= @visao == 'motoristas' ? 'Quanto cada motorista fechou no período — clique num deles para ver de onde vem o valor' : 'Uma linha por consolidação' %>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<%# ── Filtros ──────────────────────────────────────────── %>
|
||||
<%# Filtros em flex-wrap, NÃO em grade de 6 colunas fixas.
|
||||
Motivo: os breakpoints do Tailwind (md:, lg:…) enxergam a JANELA, mas o
|
||||
@@ -82,66 +99,49 @@
|
||||
tamanho legível e a linha quebra sozinha conforme o espaço REAL. %>
|
||||
<%= form_with url: consolidacoes_path, method: :get,
|
||||
class: 'bg-[#1a1a1a] border border-[#2a2a2a] rounded-xl p-4 mb-6 flex flex-wrap items-center gap-3' do |f| %>
|
||||
<%= f.text_field :nome, value: params[:nome], placeholder: 'Buscar por nome…',
|
||||
class: 'flex-1 basis-48 min-w-0 bg-[#0a0a0a] border border-[#2a2a2a] text-white rounded-lg px-3 py-2.5 focus:border-orange-500 focus:outline-none' %>
|
||||
<%# O modo de visualização é mantido ao filtrar (senão filtrar jogava o
|
||||
operador de volta para a lista). %>
|
||||
<%= hidden_field_tag :visao, @visao %>
|
||||
|
||||
<% if @visao == 'motoristas' %>
|
||||
<%= f.text_field :motorista, value: params[:motorista], placeholder: 'Buscar motorista…',
|
||||
class: 'flex-1 basis-48 min-w-0 bg-[#0a0a0a] border border-[#2a2a2a] text-white rounded-lg px-3 py-2.5 focus:border-orange-500 focus:outline-none' %>
|
||||
<% else %>
|
||||
<%= f.text_field :nome, value: params[:nome], placeholder: 'Buscar por nome…',
|
||||
class: 'flex-1 basis-48 min-w-0 bg-[#0a0a0a] border border-[#2a2a2a] text-white rounded-lg px-3 py-2.5 focus:border-orange-500 focus:outline-none' %>
|
||||
<% end %>
|
||||
|
||||
<%= f.select :status,
|
||||
options_for_select([['Todos os status', ''], ['Rascunho', 'rascunho'], ['Finalizada', 'finalizada']], params[:status]),
|
||||
{}, class: 'flex-1 basis-40 min-w-0 bg-[#0a0a0a] border border-[#2a2a2a] text-white rounded-lg px-3 py-2.5' %>
|
||||
|
||||
<%= f.select :pagamento,
|
||||
options_for_select([['Pagamento (todos)', ''], ['Pagas', 'pago'], ['Parciais', 'parcial'], ['Pendentes', 'pendente']], params[:pagamento]),
|
||||
{}, class: 'flex-1 basis-44 min-w-0 bg-[#0a0a0a] border border-[#2a2a2a] text-white rounded-lg px-3 py-2.5' %>
|
||||
<%# "Pagamento" é status DA CONSOLIDAÇÃO (todos os motoristas dela); no modo
|
||||
Por motorista cada linha já mostra pago/a receber, então o filtro sairia
|
||||
confuso — some. %>
|
||||
<% if @visao != 'motoristas' %>
|
||||
<%= f.select :pagamento,
|
||||
options_for_select([['Pagamento (todos)', ''], ['Pagas', 'pago'], ['Parciais', 'parcial'], ['Pendentes', 'pendente']], params[:pagamento]),
|
||||
{}, class: 'flex-1 basis-44 min-w-0 bg-[#0a0a0a] border border-[#2a2a2a] text-white rounded-lg px-3 py-2.5' %>
|
||||
<% end %>
|
||||
|
||||
<%= f.date_field :inicio, value: params[:inicio],
|
||||
<%# No modo Por motorista o período SEMPRE vale (default: mês corrente
|
||||
inteiro), então os campos já vêm preenchidos com o que está sendo somado. %>
|
||||
<%= f.date_field :inicio, value: (@visao == 'motoristas' ? @inicio.strftime('%Y-%m-%d') : params[:inicio]),
|
||||
class: 'flex-1 basis-36 max-w-[13rem] min-w-0 bg-[#0a0a0a] border border-[#2a2a2a] text-white rounded-lg px-3 py-2.5' %>
|
||||
|
||||
<%= f.date_field :fim, value: params[:fim],
|
||||
<%= f.date_field :fim, value: (@visao == 'motoristas' ? @fim.strftime('%Y-%m-%d') : params[:fim]),
|
||||
class: 'flex-1 basis-36 max-w-[13rem] min-w-0 bg-[#0a0a0a] border border-[#2a2a2a] text-white rounded-lg px-3 py-2.5' %>
|
||||
|
||||
<%# shrink-0 + whitespace-nowrap: os botões nunca são espremidos a ponto de
|
||||
cortar o texto — se faltar espaço, a linha quebra e eles descem inteiros. %>
|
||||
<div class="flex gap-2 shrink-0">
|
||||
<%= f.submit 'Filtrar', class: 'bg-orange-500 hover:bg-orange-600 text-black font-bold rounded-lg cursor-pointer px-5 py-2.5 whitespace-nowrap' %>
|
||||
<%= link_to 'Limpar', consolidacoes_path, class: 'px-4 py-2.5 text-gray-400 hover:text-white border border-[#2a2a2a] rounded-lg whitespace-nowrap' %>
|
||||
<%= link_to 'Limpar', consolidacoes_path(visao: @visao), class: 'px-4 py-2.5 text-gray-400 hover:text-white border border-[#2a2a2a] rounded-lg whitespace-nowrap' %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%# ── Lista ────────────────────────────────────────────── %>
|
||||
<% if @consolidacoes.any? %>
|
||||
<div class="space-y-3">
|
||||
<% @consolidacoes.each do |c| %>
|
||||
<%= link_to consolidacao_path(c),
|
||||
class: 'block bg-[#1a1a1a] border border-[#2a2a2a] hover:border-orange-500 rounded-xl p-5 transition-colors' do %>
|
||||
<div class="flex flex-col md:flex-row md:items-center md:justify-between gap-3">
|
||||
<div>
|
||||
<div class="flex items-center gap-3 mb-1">
|
||||
<h3 class="text-white font-bold text-lg"><%= c.nome %></h3>
|
||||
<%= badge_status(c.status) %>
|
||||
<% if c.finalizada? %><%= badge_pagamento(c.status_pagamento) %><% end %>
|
||||
</div>
|
||||
<p class="text-gray-400 text-sm">
|
||||
<%= icone :calendario %> <%= l c.data_inicio, format: :short %> → <%= l c.data_fim, format: :short %>
|
||||
· <%= icone :pessoa %> <%= c.consolidacao_motoristas.count %> motorista(s)
|
||||
· Criada por <%= c.criador.nome_display %>
|
||||
</p>
|
||||
<% if c.operacoes.present? %>
|
||||
<p class="text-gray-500 text-xs mt-1"><%= icone :pasta %> <%= c.operacoes_label.join(' · ') %></p>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="text-right">
|
||||
<p class="text-orange-500 font-black text-2xl"><%= moeda(c.valor_total) %></p>
|
||||
<p class="text-gray-500 text-xs"><%= c.consolidacao_entregas.count %> entregas classificadas</p>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% if @visao == 'motoristas' %>
|
||||
<%= render 'por_motorista' %>
|
||||
<% else %>
|
||||
<div class="bg-[#1a1a1a] border border-[#2a2a2a] rounded-xl p-12 text-center">
|
||||
<p class="mb-4"><%= icone :vazio, tamanho: 'w-12 h-12', cor: 'text-gray-600', espaco: false %></p>
|
||||
<p class="text-gray-400 mb-4">Nenhuma consolidação encontrada.</p>
|
||||
<%= link_to 'Criar primeira consolidação', new_consolidacao_path,
|
||||
class: 'inline-block bg-orange-500 hover:bg-orange-600 text-black font-bold px-5 py-3 rounded-lg' %>
|
||||
</div>
|
||||
<%= render 'lista' %>
|
||||
<% end %>
|
||||
|
||||
@@ -1,191 +0,0 @@
|
||||
<%# app/views/consolidacoes/totais.html.erb — Total por motorista no período %>
|
||||
<% content_for :title, 'Totais por motorista' %>
|
||||
|
||||
<div class="flex flex-wrap items-center justify-between gap-3 mb-6">
|
||||
<div>
|
||||
<h1 class="text-2xl font-bold text-white flex items-center gap-2"><%= icone :motorista, espaco: false %> Totais por motorista</h1>
|
||||
<p class="text-gray-400 text-sm mt-0.5">
|
||||
Consolidações <%= @incluir_rascunhos ? 'de qualquer status' : 'finalizadas' %>
|
||||
com período dentro de <%= l @inicio, format: :short %> → <%= l @fim, format: :short %>
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<%= link_to rotulo(:consolidacoes, 'Consolidações', cor: nil), consolidacoes_path,
|
||||
class: 'text-gray-400 hover:text-white border border-[#2a2a2a] px-4 py-3 rounded-lg min-h-[48px] flex items-center transition-colors' %>
|
||||
<%= link_to rotulo(:baixar, 'Baixar relatório (PDF)', cor: nil),
|
||||
totais_pdf_consolidacoes_path(inicio: @inicio, fim: @fim, rascunhos: (@incluir_rascunhos ? '1' : nil), motorista: @motorista),
|
||||
data: { turbo: false },
|
||||
class: 'bg-orange-500 hover:bg-orange-600 text-black font-bold px-5 py-3 rounded-lg min-h-[48px] flex items-center transition-colors' %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%# ── Filtros ──────────────────────────────────────────── %>
|
||||
<%= form_with url: totais_consolidacoes_path, method: :get,
|
||||
class: 'bg-[#1a1a1a] border border-[#2a2a2a] rounded-xl p-4 mb-6 flex flex-wrap items-center gap-3' do |f| %>
|
||||
<%# O motorista clicado viaja junto para o filtro não fechar o drill-down. %>
|
||||
<%= hidden_field_tag :motorista, @motorista if @motorista %>
|
||||
|
||||
<%= f.date_field :inicio, value: @inicio.strftime('%Y-%m-%d'),
|
||||
class: 'flex-1 basis-36 max-w-[13rem] min-w-0 bg-[#0a0a0a] border border-[#2a2a2a] text-white rounded-lg px-3 py-2.5' %>
|
||||
<%= f.date_field :fim, value: @fim.strftime('%Y-%m-%d'),
|
||||
class: 'flex-1 basis-36 max-w-[13rem] min-w-0 bg-[#0a0a0a] border border-[#2a2a2a] text-white rounded-lg px-3 py-2.5' %>
|
||||
|
||||
<label class="flex items-center gap-2 text-sm text-gray-300 whitespace-nowrap">
|
||||
<%= check_box_tag :rascunhos, '1', @incluir_rascunhos, class: 'accent-orange-500' %>
|
||||
Incluir rascunhos
|
||||
</label>
|
||||
|
||||
<div class="flex gap-2 shrink-0">
|
||||
<%= f.submit 'Filtrar', class: 'bg-orange-500 hover:bg-orange-600 text-black font-bold rounded-lg cursor-pointer px-5 py-2.5 whitespace-nowrap' %>
|
||||
<%= link_to 'Limpar', totais_consolidacoes_path, class: 'px-4 py-2.5 text-gray-400 hover:text-white border border-[#2a2a2a] rounded-lg whitespace-nowrap' %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%# ── KPIs do período ──────────────────────────────────── %>
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-4 gap-4 mb-6">
|
||||
<div class="bg-[#1a1a1a] border border-[#2a2a2a] rounded-xl p-5">
|
||||
<p class="text-gray-400 text-xs uppercase tracking-wide"><%= icone :dinheiro %> Total do período</p>
|
||||
<p class="text-orange-500 font-black text-3xl mt-1 whitespace-nowrap"><%= moeda(@totais.total_geral) %></p>
|
||||
<p class="text-gray-500 text-xs mt-1"><%= @totais.total_consolidacoes %> consolidação(ões) · <%= @totais.linhas.size %> motorista(s)</p>
|
||||
</div>
|
||||
<div class="bg-[#1a1a1a] border border-[#2a2a2a] rounded-xl p-5">
|
||||
<p class="text-gray-400 text-xs uppercase tracking-wide"><%= icone :sucesso, cor: 'text-green-400' %> Pago</p>
|
||||
<p class="text-green-400 font-black text-3xl mt-1 whitespace-nowrap"><%= moeda(@totais.total_pago) %></p>
|
||||
</div>
|
||||
<div class="bg-[#1a1a1a] border border-[#2a2a2a] rounded-xl p-5">
|
||||
<p class="text-gray-400 text-xs uppercase tracking-wide"><%= icone :parcial, cor: 'text-amber-400' %> A pagar</p>
|
||||
<p class="text-amber-400 font-black text-3xl mt-1 whitespace-nowrap"><%= moeda(@totais.total_pendente) %></p>
|
||||
</div>
|
||||
<div class="bg-[#1a1a1a] border border-[#2a2a2a] rounded-xl p-5">
|
||||
<p class="text-gray-400 text-xs uppercase tracking-wide"><%= icone :ticket %> Média por motorista</p>
|
||||
<p class="text-white font-black text-3xl mt-1 whitespace-nowrap">
|
||||
<%= moeda(@totais.linhas.any? ? @totais.total_geral / @totais.linhas.size : 0) %>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% if @totais.vazio? %>
|
||||
<div class="bg-[#1a1a1a] border border-[#2a2a2a] rounded-xl p-12 text-center">
|
||||
<p class="mb-4"><%= icone :vazio, tamanho: 'w-12 h-12', cor: 'text-gray-600', espaco: false %></p>
|
||||
<p class="text-gray-400">Nenhuma consolidação <%= @incluir_rascunhos ? '' : 'finalizada ' %>com período dentro dessa faixa.</p>
|
||||
<p class="text-gray-500 text-sm mt-1">Amplie o período ou marque "Incluir rascunhos".</p>
|
||||
</div>
|
||||
<% else %>
|
||||
<%# ── Tabela: total por motorista (clique abre a composição) ── %>
|
||||
<div class="bg-[#1a1a1a] border border-[#2a2a2a] rounded-xl overflow-hidden mb-6">
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full text-sm">
|
||||
<thead class="bg-[#0a0a0a] text-gray-400 uppercase text-xs">
|
||||
<tr>
|
||||
<th class="text-left px-4 py-3">Motorista</th>
|
||||
<th class="text-right px-4 py-3">Consolidações</th>
|
||||
<th class="text-right px-4 py-3">Lançamentos</th>
|
||||
<th class="text-right px-4 py-3">Pago</th>
|
||||
<th class="text-right px-4 py-3">A pagar</th>
|
||||
<th class="text-right px-4 py-3">Total</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @totais.linhas.each do |l| %>
|
||||
<% aberto = @motorista == l[:motorista] %>
|
||||
<tr class="border-t border-[#2a2a2a] <%= 'bg-orange-500/10' if aberto %> hover:bg-[#222]">
|
||||
<%# O nome é um LINK de verdade (e não um <tr onclick>): abre/fecha
|
||||
a composição daquele motorista e continua acessível pelo teclado. %>
|
||||
<td class="px-4 py-3 whitespace-nowrap">
|
||||
<%= link_to totais_consolidacoes_path(inicio: @inicio, fim: @fim,
|
||||
rascunhos: (@incluir_rascunhos ? '1' : nil),
|
||||
motorista: (aberto ? nil : l[:motorista])),
|
||||
class: 'text-white font-semibold hover:text-orange-500 flex items-center gap-1' do %>
|
||||
<%= icone(aberto ? :expandir : :avancar, cor: 'text-gray-500', espaco: false) %><%= l[:motorista] %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-right text-gray-300"><%= l[:consolidacoes] %></td>
|
||||
<td class="px-4 py-3 text-right text-gray-300"><%= l[:lancamentos] %></td>
|
||||
<td class="px-4 py-3 text-right text-green-400"><%= moeda(l[:valor_pago]) %></td>
|
||||
<td class="px-4 py-3 text-right text-amber-400"><%= moeda(l[:valor_pendente]) %></td>
|
||||
<td class="px-4 py-3 text-right text-orange-500 font-black whitespace-nowrap"><%= moeda(l[:valor_total]) %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
<tfoot class="bg-[#0a0a0a] text-white font-bold">
|
||||
<tr>
|
||||
<td class="px-4 py-3">TOTAL</td>
|
||||
<td class="px-4 py-3 text-right"><%= @totais.total_consolidacoes %></td>
|
||||
<td class="px-4 py-3"></td>
|
||||
<td class="px-4 py-3 text-right text-green-400"><%= moeda(@totais.total_pago) %></td>
|
||||
<td class="px-4 py-3 text-right text-amber-400"><%= moeda(@totais.total_pendente) %></td>
|
||||
<td class="px-4 py-3 text-right text-orange-500"><%= moeda(@totais.total_geral) %></td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center justify-between gap-2 px-4 py-3 border-t border-[#2a2a2a]">
|
||||
<p class="text-gray-500 text-xs">
|
||||
<%= icone :dica %> Clique num motorista para ver as consolidações que compõem o total dele.
|
||||
</p>
|
||||
<%# PDF sem a composição de cada motorista — para períodos com muita gente,
|
||||
quando só o resumo interessa. %>
|
||||
<%= link_to 'Baixar só o resumo (PDF)',
|
||||
totais_pdf_consolidacoes_path(inicio: @inicio, fim: @fim, rascunhos: (@incluir_rascunhos ? '1' : nil), detalhar: '0'),
|
||||
data: { turbo: false },
|
||||
class: 'text-gray-400 hover:text-orange-500 text-xs underline whitespace-nowrap' %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%# ── Drill-down: as consolidações que compõem o total ── %>
|
||||
<% if @detalhe %>
|
||||
<div class="bg-[#1a1a1a] border border-orange-500/40 rounded-xl p-5">
|
||||
<div class="flex flex-wrap items-center justify-between gap-3 mb-4">
|
||||
<div>
|
||||
<h2 class="text-white font-bold text-lg flex items-center gap-2">
|
||||
<%= icone :composicao, espaco: false %> Composição de <%= @motorista %>
|
||||
</h2>
|
||||
<p class="text-gray-400 text-sm mt-0.5">
|
||||
<%= @detalhe.size %> consolidação(ões) no período ·
|
||||
<span class="text-orange-500 font-bold"><%= moeda(@detalhe.sum { |cm| cm.valor_total || 0 }) %></span>
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<%= link_to rotulo(:baixar, 'PDF deste motorista', cor: nil),
|
||||
totais_pdf_consolidacoes_path(inicio: @inicio, fim: @fim, rascunhos: (@incluir_rascunhos ? '1' : nil), motorista: @motorista),
|
||||
data: { turbo: false },
|
||||
class: 'bg-orange-500 hover:bg-orange-600 text-black font-bold px-4 py-2.5 rounded-lg flex items-center' %>
|
||||
<%= link_to rotulo(:fechar, 'Fechar', cor: nil),
|
||||
totais_consolidacoes_path(inicio: @inicio, fim: @fim, rascunhos: (@incluir_rascunhos ? '1' : nil)),
|
||||
class: 'text-gray-400 hover:text-white border border-[#2a2a2a] px-4 py-2.5 rounded-lg flex items-center' %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% if @detalhe.empty? %>
|
||||
<p class="text-gray-400 text-sm">Nenhuma consolidação desse motorista neste período.</p>
|
||||
<% end %>
|
||||
|
||||
<div class="space-y-3">
|
||||
<% @detalhe.each do |cm| %>
|
||||
<% c = cm.consolidacao %>
|
||||
<%= link_to consolidacao_path(c),
|
||||
class: 'block bg-[#0a0a0a] border border-[#2a2a2a] hover:border-orange-500 rounded-xl p-4 transition-colors' do %>
|
||||
<div class="flex flex-col md:flex-row md:items-center md:justify-between gap-2">
|
||||
<div>
|
||||
<div class="flex items-center gap-2 flex-wrap">
|
||||
<span class="text-white font-bold"><%= c.nome %></span>
|
||||
<%= badge_status(c.status) %>
|
||||
<%= badge_pagamento(cm.pago? ? :pago : :pendente) %>
|
||||
</div>
|
||||
<p class="text-gray-400 text-sm mt-1">
|
||||
<%= icone :calendario %> <%= l c.data_inicio, format: :short %> → <%= l c.data_fim, format: :short %>
|
||||
<% if cm.pago? %>
|
||||
· <%= icone :dinheiro, cor: 'text-green-400' %> Pago em <%= l cm.pago_em.to_date, format: :short %>
|
||||
<% if cm.forma_pagamento.present? %>via <%= cm.forma_pagamento.humanize %><% end %>
|
||||
<% if cm.nota_fiscal.present? %>· NF <%= cm.nota_fiscal %><% end %>
|
||||
<% end %>
|
||||
</p>
|
||||
</div>
|
||||
<p class="text-orange-500 font-black text-2xl whitespace-nowrap"><%= moeda(cm.valor_total) %></p>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
Reference in New Issue
Block a user