Files
Reem-Notas/app/views/consolidacao_entregas/revisar.html.erb
victor fedf5bfcc9 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
2026-06-16 14:45:06 -03:00

119 lines
5.6 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<%# app/views/consolidacao_entregas/revisar.html.erb — PASSO 3: Revisar %>
<% content_for :title, "Revisar — #{@motorista}" %>
<div class="max-w-3xl mx-auto">
<div class="mb-6">
<%= link_to '← Voltar (Passo 2)',
validar_consolidacao_consolidacao_entregas_path(@consolidacao, motorista: @motorista),
class: 'text-gray-500 hover:text-orange-500 text-sm' %>
<h1 class="text-2xl font-bold text-white mt-2">📋 Revisão — <%= @motorista %></h1>
<p class="text-gray-400 text-sm"><%= @consolidacao.nome %></p>
</div>
<%# Resumo por tipo %>
<div class="grid grid-cols-2 md:grid-cols-4 gap-3 mb-6">
<% [
['entrega_normal', 'Normal', 'bg-orange-500 text-black'],
['retirada', 'Retirada', 'bg-orange-800 text-white'],
['bonus', 'Bônus', 'bg-white text-black'],
['desconto', 'Desconto', 'bg-black text-white border border-gray-700']
].each do |tipo, label, cores| %>
<div class="<%= cores %> rounded-xl p-4 text-center">
<p class="font-black text-3xl"><%= @resumo[tipo] || 0 %></p>
<p class="text-sm font-semibold"><%= label %></p>
</div>
<% end %>
</div>
<%# Total %>
<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"><%= @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-4">
<table class="w-full text-sm">
<thead class="bg-[#0a0a0a] text-gray-400">
<tr>
<th class="text-left px-4 py-3">Tracking / NF</th>
<th class="text-left px-4 py-3">Tipo</th>
<th class="text-right px-4 py-3">Valor</th>
</tr>
</thead>
<tbody class="divide-y divide-[#2a2a2a]">
<% @classificacoes.each do |c| %>
<tr>
<td class="px-4 py-3 text-white font-mono text-xs"><%= c.tracking_id %></td>
<td class="px-4 py-3">
<span class="<%= c.tipo_cor[:bg] %> <%= c.tipo_cor[:text] %> px-2 py-1 rounded text-xs font-bold">
<%= c.tipo_cor[:label] %>
</span>
</td>
<td class="px-4 py-3 text-right font-bold <%= c.desconto? ? 'text-red-400' : 'text-white' %>">
<%= c.desconto? ? '-' : '' %><%= moeda(c.valor_aplicado) %>
</td>
</tr>
<% end %>
</tbody>
</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 %>
<%= link_to "Próximo motorista: #{@proximo} →",
validar_consolidacao_consolidacao_entregas_path(@consolidacao, motorista: @proximo),
class: 'flex-1 bg-orange-500 hover:bg-orange-600 text-black font-bold py-3.5 rounded-lg min-h-[48px] flex items-center justify-center text-center' %>
<% end %>
<%= link_to '💾 Salvar rascunho e voltar', wizard_consolidacao_path(@consolidacao),
class: 'flex-1 bg-[#1a1a1a] hover:bg-[#2a2a2a] text-white border border-[#2a2a2a] font-bold py-3.5 rounded-lg min-h-[48px] flex items-center justify-center' %>
</div>
</div>