<?php $title='Edit Unit'; ob_start(); ?>
<h3>Edit Unit</h3>
<form method="POST" action="/samanta_crm/units/<?= $unit['id'] ?>/update">
  <div class="mb-2"><label class="form-label">Code *</label><input name="code" value="<?= htmlspecialchars($unit['code']) ?>" class="form-control form-control-sm" required></div>
  <div class="mb-2"><label class="form-label">Name *</label><input name="name" value="<?= htmlspecialchars($unit['name']) ?>" class="form-control form-control-sm" required></div>
  <div class="mb-2"><label class="form-label">Scope</label>
    <select name="scope" class="form-select form-select-sm">
      <?php $scopes=['product'=>'Product','ingredient'=>'Ingredient','both'=>'Both']; foreach($scopes as $k=>$label): ?>
        <option value="<?= $k ?>" <?= ($unit['scope']??'product')===$k?'selected':''; ?>><?= $label ?></option>
      <?php endforeach; ?>
    </select>
  </div>
  <div class="mb-2"><label class="form-label">Sort Order</label><input name="sort_order" value="<?= htmlspecialchars($unit['sort_order']) ?>" class="form-control form-control-sm"></div>
  <div class="form-check mb-2"><input type="checkbox" class="form-check-input" id="u_active" name="is_active" <?= $unit['is_active']?'checked':'' ?>><label for="u_active" class="form-check-label"><?= __("common.active", "Active") ?></label></div>
  <button class="btn btn-primary"><?= __("common.update", "Update") ?></button> <a class="btn btn-secondary" href="/samanta_crm/units"><?= __("common.cancel", "Cancel") ?></a>
</form>
<?php $content=ob_get_clean(); include '../app/Views/layout.php'; ?>
