Files
Reem-Notas/app/views/admin/romaneios/index.html.erb

145 lines
6.9 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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/admin/romaneios/index.html.erb %>
<div class="space-y-6">
<div>
<h1 class="text-2xl font-bold text-white">Romaneio de entrega</h1>
<p class="text-gray-400 text-sm mt-0.5">
Monta o "CONTROLE DE ENTREGA" — uma folha por veículo, assinada pelo motorista na retirada
</p>
</div>
<%= render 'shared/flash' %>
<div class="p-4 bg-blue-900/20 border border-blue-500/40 rounded-xl text-blue-200/90 text-sm flex items-start gap-2">
<span class="text-base leading-none"></span>
<p>
A coluna <strong>APARELHO</strong> é marcada sozinha para quem está como
<strong>NOVO</strong> na operação do mês, e o <strong>telefone</strong> vem da própria
operação — não é preciso subir uma segunda planilha. Tudo continua editável na tela
antes de imprimir.
</p>
</div>
<%# Importação %>
<div class="bg-[#111] border border-white/5 rounded-2xl p-5 space-y-4">
<h2 class="text-white font-semibold">Importar plano</h2>
<%= form_with url: admin_romaneios_path, method: :post, multipart: true,
data: { turbo: false }, class: 'space-y-4' do %>
<div class="grid grid-cols-1 sm:grid-cols-3 gap-3">
<div>
<label class="block text-sm font-medium text-gray-300 mb-1.5">Data do plano</label>
<input type="date" name="planned_date" required value="<%= @data_padrao %>"
class="w-full bg-[#1a1a1a] border border-white/10 rounded-xl px-3 py-3 text-white
focus:outline-none focus:border-orange-500 min-h-[48px]">
</div>
<div>
<label class="block text-sm font-medium text-gray-300 mb-1.5">
Operação do mês
<span class="text-gray-500 font-normal">(APARELHO e telefone)</span>
</label>
<select name="operacao_tabela"
class="w-full bg-[#1a1a1a] border border-white/10 rounded-xl px-3 py-3 text-white
focus:outline-none focus:border-orange-500 min-h-[48px]">
<option value="">Sem operação — só o que o plano trouxer</option>
<% @operacoes_agrupadas.each do |titulo, ops| %>
<optgroup label="<%= titulo %>">
<% ops.each do |op| %>
<option value="<%= op[:tabela] %>"><%= op[:label] %></option>
<% end %>
</optgroup>
<% end %>
</select>
</div>
<div>
<label class="block text-sm font-medium text-gray-300 mb-1.5">
PLANO <span class="text-gray-500 font-normal">(canto direito do PDF)</span>
</label>
<input type="text" name="rotulo_plano" placeholder="Ex.: EMAD 09.2026"
class="w-full bg-[#1a1a1a] border border-white/10 rounded-xl px-3 py-3 text-white
placeholder-gray-600 focus:outline-none focus:border-orange-500 min-h-[48px]">
</div>
</div>
<div class="flex flex-col sm:flex-row gap-3 sm:items-center">
<button type="submit"
class="px-6 py-3 bg-[#f97316] hover:bg-orange-500 text-white font-semibold rounded-xl
transition-colors min-h-[48px] whitespace-nowrap">
<%= icone :buscar, cor: nil %> Buscar no SimpliRoute
</button>
<%# Reserva: o plano do dia pode ainda não estar publicado. %>
<details class="flex-1">
<summary class="cursor-pointer text-sm text-gray-400 hover:text-white select-none py-3">
Ou enviar a planilha do plano (.xlsx)
</summary>
<div class="mt-2 flex flex-col sm:flex-row gap-3">
<input type="file" name="arquivo" accept=".xlsx"
class="flex-1 text-sm text-gray-300 file:mr-3 file:py-2.5 file:px-4 file:rounded-lg
file:border-0 file:bg-[#1a1a1a] file:text-gray-200 file:cursor-pointer">
<button type="submit" formaction="<%= importar_planilha_admin_romaneios_path %>"
class="px-5 py-3 bg-[#1a1a1a] hover:bg-[#242424] text-white border border-white/10
rounded-xl min-h-[48px] whitespace-nowrap">
<%= icone :baixar, cor: nil %> Enviar planilha
</button>
</div>
<p class="text-xs text-gray-500 mt-2">
Use quando o plano do dia ainda não estiver publicado no SimpliRoute.
O arquivo é lido na hora e não fica guardado no sistema.
</p>
</details>
</div>
<% end %>
</div>
<%# Romaneios já importados %>
<div class="bg-[#111] border border-white/5 rounded-2xl overflow-hidden">
<% if @romaneios.empty? %>
<div class="p-8 text-center">
<p class="text-gray-400">Nenhum romaneio ainda.</p>
<p class="text-gray-500 text-sm mt-1">Escolha a data do plano acima e clique em “Buscar no SimpliRoute”.</p>
</div>
<% else %>
<table class="w-full text-sm">
<thead class="bg-[#1a1a1a] text-gray-400 text-xs uppercase tracking-wider">
<tr>
<th class="text-left px-4 py-3">Data</th>
<th class="text-left px-4 py-3">Plano</th>
<th class="text-left px-4 py-3">Operação</th>
<th class="text-left px-4 py-3">Veículos</th>
<th class="text-left px-4 py-3">Origem</th>
<th class="px-4 py-3"></th>
</tr>
</thead>
<tbody class="divide-y divide-white/5">
<% @romaneios.each do |r| %>
<tr class="hover:bg-white/5">
<td class="px-4 py-3 text-white"><%= l r.planned_date, format: '%d/%m/%Y' %></td>
<td class="px-4 py-3 text-gray-200"><%= r.rotulo_plano.presence || '—' %></td>
<td class="px-4 py-3 text-gray-400"><%= r.operacao_label || '—' %></td>
<td class="px-4 py-3 text-gray-400"><%= r.romaneio_veiculos.size %></td>
<td class="px-4 py-3">
<span class="px-2 py-0.5 rounded-md text-xs bg-white/5 text-gray-300"><%= r.origem %></span>
</td>
<td class="px-4 py-3 text-right whitespace-nowrap">
<%= link_to rotulo(:editar, 'Abrir'), admin_romaneio_path(r),
class: 'text-orange-400 hover:text-orange-300 font-medium' %>
<%# button_to em BLOCO: sem bloco ele vira <input type="submit">, que
não aceita o SVG do ícone dentro (ver ApplicationHelper#rotulo). %>
<%= button_to admin_romaneio_path(r), method: :delete,
form: { data: { turbo_confirm: 'Excluir este romaneio e todas as edições feitas nele?' },
class: 'inline-block ml-3' },
class: 'text-gray-500 hover:text-red-400' do %>
<%= icone :excluir, cor: nil %> Excluir
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
</div>
</div>