<%- include('partials/header') %>
<div class="page-head">
  <h1>Historique des prix envoyés</h1>
  <a class="btn btn-ghost" href="<%= base %>/sync">← Synchronisation</a>
</div>
<form class="toolbar" method="get">
  <input name="q" value="<%= q %>" placeholder="Référence, ID ou nom">
  <button class="btn">Rechercher</button>
  <span class="muted">500 dernières modifications</span>
</form>
<div class="card">
<table class="table">
  <thead><tr><th>Date</th><th>Tâche</th><th>ID</th><th>Référence</th><th>Produit</th><th class="num">Ancien HT</th><th class="num">Nouveau HT</th><th class="num">Ancien achat</th><th class="num">Nouvel achat</th></tr></thead>
  <tbody>
  <% rows.forEach(h => { %>
    <tr>
      <td class="small"><%= h.created_at %></td>
      <td><a href="<%= base %>/sync/jobs/<%= h.job_id %>">#<%= h.job_id %></a></td>
      <td><%= h.id_product %><%= h.id_product_attribute ? '/' + h.id_product_attribute : '' %></td>
      <td><%= h.reference %></td><td><%= h.name %></td>
      <td class="num"><%= h.old_price.toFixed(2) %></td>
      <td class="num <%= h.new_price > h.old_price ? 'up' : 'down' %>"><%= h.new_price.toFixed(2) %></td>
      <td class="num"><%= h.old_wholesale.toFixed(2) %></td><td class="num"><%= h.new_wholesale.toFixed(2) %></td>
    </tr>
  <% }) %>
  <% if (!rows.length) { %><tr><td colspan="9" class="muted">Aucune modification enregistrée.</td></tr><% } %>
  </tbody>
</table>
</div>
<%- include('partials/footer') %>
