Criação da visão geral da consolidação por motorista
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
<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? %>
|
||||
|
||||
191
app/views/consolidacoes/totais.html.erb
Normal file
191
app/views/consolidacoes/totais.html.erb
Normal file
@@ -0,0 +1,191 @@
|
||||
<%# 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