Globinours/app/Views/settings_catalogs.php

17 lines
2.7 KiB
PHP
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.

<?php require __DIR__ . '/settings_nav.php';
$labels = ['medication'=>t('animal.medication'),'vaccine'=>t('animal.vaccine'),'dewormer'=>t('animals.dewormer'),'manufacturer'=>t('animal.manufacturer')];
$extras = ['medication'=>t('animal.molecule'),'vaccine'=>t('catalog.code'),'dewormer'=>t('catalog.active_ingredient'),'manufacturer'=>'']; ?>
<?php if ($saved): ?><div class="alert alert-success"><?= h(t('catalog.saved')) ?></div><?php endif; ?>
<?php if ($error !== ''): ?><div class="alert alert-danger"><?= h($error) ?></div><?php endif; ?>
<div class="mb-3"><h2 class="mb-1"><?= h(t('settings.catalogs')) ?></h2><div class="text-muted"><?= h(t('catalog.admin_help')) ?></div></div>
<div class="row g-3">
<?php foreach ($catalogs as $type => $rows): ?><div class="col-12 col-xl-6"><div class="card h-100">
<div class="card-header"><h3 class="card-title"><?= h($labels[$type]) ?></h3></div><div class="card-body">
<form class="row g-2 mb-3" method="post" action="/settings/catalogs/save"><input type="hidden" name="csrf" value="<?= h(Auth::csrf()) ?>"><input type="hidden" name="type" value="<?= h($type) ?>">
<div class="<?= $type === 'manufacturer' ? 'col-9' : 'col-6' ?>"><input class="form-control" name="name" placeholder="<?= h(t('common.name')) ?>" required></div>
<?php if ($type !== 'manufacturer'): ?><div class="col-3"><input class="form-control" name="extra" placeholder="<?= h($extras[$type]) ?>"></div><?php endif; ?><div class="col-3"><button class="btn btn-primary w-100">+ <?= h(t('common.add')) ?></button></div></form>
<div class="table-responsive"><table class="table table-sm table-vcenter"><tbody><?php foreach ($rows as $row): ?><tr><td>
<form class="d-flex gap-2" method="post" action="/settings/catalogs/save"><input type="hidden" name="csrf" value="<?= h(Auth::csrf()) ?>"><input type="hidden" name="type" value="<?= h($type) ?>"><input type="hidden" name="id" value="<?= (int)$row['id'] ?>"><input class="form-control form-control-sm" name="name" value="<?= h($row['name']) ?>" required><?php if ($type !== 'manufacturer'): ?><input class="form-control form-control-sm" name="extra" value="<?= h($row['extra'] ?? '') ?>" placeholder="<?= h($extras[$type]) ?>"><?php endif; ?><button class="btn btn-sm btn-outline-primary">✓</button></form>
</td><td class="w-1"><form method="post" action="/settings/catalogs/delete" onsubmit="return confirm(<?= h(json_encode(t('catalog.delete_confirm'), JSON_HEX_APOS|JSON_HEX_QUOT)) ?>)"><input type="hidden" name="csrf" value="<?= h(Auth::csrf()) ?>"><input type="hidden" name="type" value="<?= h($type) ?>"><input type="hidden" name="id" value="<?= (int)$row['id'] ?>"><button class="btn btn-sm btn-outline-danger">×</button></form></td></tr><?php endforeach; ?></tbody></table></div>
</div></div></div><?php endforeach; ?>
</div>