<?php $title='Restocks'; ob_start(); ?>
<h1 class="h5 mb-3">Restocks</h1>
<?php if(isset($_SESSION['success'])): ?><div class="alert alert-success"><?=htmlspecialchars($_SESSION['success']); unset($_SESSION['success']);?></div><?php endif; ?>
<a href="/samanta_crm/restocks/create" class="btn btn-sm btn-primary mb-3">New Restock</a>
<table class="table table-sm table-striped align-middle">
  <thead><tr><th>Date</th><th>ID</th><th>Supplier</th><th>Summary</th><th>Notes</th><th style="width:120px"><?= __("common.actions", "Actions") ?></th></tr></thead>
  <tbody>
  <?php foreach($restocks as $r): ?>
    <tr>
      <td><?=htmlspecialchars($r['restock_date']);?></td>
      <td><?=$r['id'];?></td>
      <td><?=htmlspecialchars($r['supplier']??'');?></td>
      <td class="small">
        <?php $cnt=(int)($r['item_count']??0); echo $cnt.' items'; ?>
      </td>
      <td><?=htmlspecialchars($r['notes']);?></td>
      <td>
        <a class="btn btn-sm btn-outline-secondary" href="/samanta_crm/restocks/<?=$r['id'];?>">View</a>
        <a class="btn btn-sm btn-outline-primary" href="/samanta_crm/restocks/<?=$r['id'];?>/edit"><?= __("common.edit", "Edit") ?></a>
      </td>
    </tr>
  <?php endforeach; ?>
  </tbody>
</table>
<a href="/samanta_crm/stock/ingredients" class="btn btn-sm btn-outline-secondary">Stock</a>
<?php $content=ob_get_clean(); require __DIR__.'/../layout.php'; ?>
