Corrige dashboard por período, CRUD de usuário, PDFs e paginação na revisão

- Dashboard: no_periodo passa a cobrir o dia inteiro (planned_date é timestamp),
  corrigindo período que zerava ao terminar no dia dos dados
- Dashboard: card de consolidações filtra por sobreposição de datas (não created_at)
- Usuários: adiciona helper role_options_for_select (corrige edição/criação)
- Consolidação: set_consolidacao nas actions de PDF/preview (corrige
  Pundit::NotDefinedError em Relatório Individual, Gerar Holerite e Preview)
- Revisão: paginação com Pagy (20/página + seletor 20/50/100)
- Nova consolidação: veículos filtrados pelo(s) motorista(s) no período
This commit is contained in:
2026-06-16 14:45:06 -03:00
parent aad167873f
commit fedf5bfcc9
17 changed files with 14917 additions and 24 deletions

View File

@@ -30,11 +30,24 @@
<div class="bg-[#1a1a1a] border border-orange-500 rounded-xl p-6 mb-6 text-center">
<p class="text-gray-400 text-sm mb-1">Total a pagar — <%= @motorista %></p>
<p class="text-orange-500 font-black text-4xl"><%= moeda(@total) %></p>
<p class="text-gray-500 text-xs mt-1"><%= @classificacoes.map(&:tracking_id).uniq.size %> entregas classificadas (<%= @classificacoes.size %> pilares)</p>
<p class="text-gray-500 text-xs mt-1"><%= @total_classificadas %> entregas classificadas (<%= @total_pilares %> pilares)</p>
</div>
<%# Seletor de itens por página %>
<form method="get" action="<%= revisar_consolidacao_consolidacao_entregas_path(@consolidacao) %>"
class="flex items-center justify-end gap-2 mb-2">
<input type="hidden" name="motorista" value="<%= @motorista %>">
<label class="text-gray-400 text-sm">Itens por página</label>
<select name="por_pagina" onchange="this.form.submit()"
class="bg-[#1a1a1a] border border-[#2a2a2a] text-white rounded-lg px-3 py-2 text-sm focus:border-orange-500 focus:outline-none cursor-pointer">
<% [20, 50, 100].each do |n| %>
<option value="<%= n %>" <%= 'selected' if @por_pagina == n %>><%= n %></option>
<% end %>
</select>
</form>
<%# Detalhe das classificações %>
<div class="bg-[#1a1a1a] border border-[#2a2a2a] rounded-xl overflow-hidden mb-6">
<div class="bg-[#1a1a1a] border border-[#2a2a2a] rounded-xl overflow-hidden mb-4">
<table class="w-full text-sm">
<thead class="bg-[#0a0a0a] text-gray-400">
<tr>
@@ -61,6 +74,37 @@
</table>
</div>
<%# Navegação de páginas %>
<% if @pagy.pages > 1 %>
<% pag = ->(p) { revisar_consolidacao_consolidacao_entregas_path(@consolidacao, motorista: @motorista, por_pagina: @por_pagina, page: p) } %>
<nav class="flex items-center justify-center gap-1.5 mb-6 flex-wrap">
<% if @pagy.prev %>
<%= link_to '', pag.call(@pagy.prev),
class: 'min-w-[40px] min-h-[40px] flex items-center justify-center rounded-lg border border-[#2a2a2a] text-white hover:border-orange-500' %>
<% else %>
<span class="min-w-[40px] min-h-[40px] flex items-center justify-center rounded-lg border border-[#2a2a2a] text-gray-700"></span>
<% end %>
<% @pagy.series.each do |item| %>
<% if item == :gap %>
<span class="px-2 text-gray-500">…</span>
<% elsif item.is_a?(String) %>
<span class="min-w-[40px] min-h-[40px] flex items-center justify-center rounded-lg bg-orange-500 text-black font-bold"><%= item %></span>
<% else %>
<%= link_to item, pag.call(item),
class: 'min-w-[40px] min-h-[40px] flex items-center justify-center rounded-lg border border-[#2a2a2a] text-white hover:border-orange-500' %>
<% end %>
<% end %>
<% if @pagy.next %>
<%= link_to '', pag.call(@pagy.next),
class: 'min-w-[40px] min-h-[40px] flex items-center justify-center rounded-lg border border-[#2a2a2a] text-white hover:border-orange-500' %>
<% else %>
<span class="min-w-[40px] min-h-[40px] flex items-center justify-center rounded-lg border border-[#2a2a2a] text-gray-700"></span>
<% end %>
</nav>
<% end %>
<%# Ações finais %>
<div class="flex flex-col md:flex-row gap-3">
<% if @proximo %>