parent
1378aefa9c
commit
b906cf7b88
11 changed files with 96 additions and 13 deletions
|
|
@ -31,9 +31,9 @@
|
|||
<div class="col-lg-6">
|
||||
<section class="card h-100">
|
||||
<div class="card-body">
|
||||
<span class="badge bg-blue-lt mb-2">1.0.0-rc.12</span>
|
||||
<h3>Tarifs d’adoption par espèce</h3>
|
||||
<p class="text-muted">Montants avant ou après stérilisation, avec possibilité de laisser le tarif libre.</p>
|
||||
<span class="badge bg-blue-lt mb-2">1.0.0-rc.13</span>
|
||||
<h3>Catalogue vétérinaire modifiable</h3>
|
||||
<p class="text-muted">Tarifs modifiables ou supprimables tout en préservant les dépenses historiques.</p>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -98,36 +98,37 @@
|
|||
<div class="text-muted small"><?= h(t('pricing.add_label_help')) ?></div>
|
||||
</div>
|
||||
</div>
|
||||
<form method="post" action="/settings/pricing/tariff">
|
||||
<form method="post" action="/settings/pricing/tariff" id="tariffForm">
|
||||
<input type="hidden" name="id" id="tariffId" value="0">
|
||||
<div class="card-body row g-3">
|
||||
<div class="col-md-4"><label class="form-label required"><?= h(t('pricing.structure')) ?></label><select
|
||||
class="form-select" name="clinic_contact_id" required>
|
||||
class="form-select" name="clinic_contact_id" id="tariffClinic" required>
|
||||
<option value="">—</option><?php foreach ($clinics as $c): ?><option value="<?= (int)$c['id'] ?>">
|
||||
<?= h($c['name']) ?></option><?php endforeach; ?>
|
||||
</select></div>
|
||||
<div class="col-md-5"><label class="form-label required"><?= h(t('pricing.label')) ?></label><input
|
||||
class="form-control" name="label" required placeholder="<?= h(t('pricing.label_example')) ?>"></div>
|
||||
class="form-control" name="label" id="tariffLabel" required placeholder="<?= h(t('pricing.label_example')) ?>"></div>
|
||||
<div class="col-md-3"><label class="form-label"><?= h(t('pricing.catalog_price')) ?></label>
|
||||
<div class="input-group"><input class="form-control" name="amount" inputmode="decimal" required><span
|
||||
<div class="input-group"><input class="form-control" name="amount" id="tariffAmount" inputmode="decimal" required><span
|
||||
class="input-group-text">€</span></div>
|
||||
</div>
|
||||
<div class="col-md-3"><label class="form-label"><?= h(t('settings.category')) ?></label><select
|
||||
class="form-select" name="category"><?php foreach ($categories as $k => $v): ?><option
|
||||
class="form-select" name="category" id="tariffCategory"><?php foreach ($categories as $k => $v): ?><option
|
||||
value="<?= h($k) ?>"><?= h(PricingService::categoryLabel($k)) ?></option>
|
||||
<?php endforeach; ?></select></div>
|
||||
<div class="col-md-3"><label class="form-label"><?= h(t('pricing.discount_group')) ?></label><select
|
||||
class="form-select" name="discount_group"><?php foreach ($groups as $k => $v): ?><option
|
||||
class="form-select" name="discount_group" id="tariffGroup"><?php foreach ($groups as $k => $v): ?><option
|
||||
value="<?= h($k) ?>"><?= h(PricingService::groupLabel($k)) ?></option>
|
||||
<?php endforeach; ?></select></div>
|
||||
<div class="col-md-2"><label class="form-label"><?= h(t('pricing.unit')) ?></label><input
|
||||
class="form-control" name="unit_label" value="acte"></div>
|
||||
class="form-control" name="unit_label" id="tariffUnit" value="acte"></div>
|
||||
<div class="col-md-4"><label class="form-label"><?= h(t('pricing.linked_medication')) ?> <span
|
||||
class="text-muted">(<?= h(t('common.optional')) ?>)</span></label><select class="form-select"
|
||||
name="medication_id">
|
||||
name="medication_id" id="tariffMedication">
|
||||
<option value="">—</option><?php foreach ($medications as $m): ?><option
|
||||
value="<?= (int)$m['id'] ?>"><?= h($m['name']) ?></option><?php endforeach; ?>
|
||||
</select></div>
|
||||
<div class="col-12"><label class="form-check"><input class="form-check-input" type="checkbox" name="active"
|
||||
<div class="col-12"><label class="form-check"><input class="form-check-input" type="checkbox" name="active" id="tariffActive"
|
||||
checked><span class="form-check-label"><?= h(t('pricing.active_tariff')) ?></span></label></div>
|
||||
</div>
|
||||
<div class="card-footer text-end"><button class="btn btn-primary"><?= h(t('pricing.add_tariff')) ?></button>
|
||||
|
|
@ -149,6 +150,7 @@
|
|||
<th class="text-end"><?= h(t('pricing.catalog')) ?></th>
|
||||
<th class="text-end"><?= h(t('pricing.estimated_cost')) ?></th>
|
||||
<th><?= h(t('pricing.state')) ?></th>
|
||||
<th class="text-end"><?= h(t('common.actions')) ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody><?php foreach ($tariffs as $t): ?><tr>
|
||||
|
|
@ -164,7 +166,27 @@
|
|||
<td><span
|
||||
class="badge <?= $t['active'] ? 'bg-green-lt' : 'bg-secondary-lt' ?>"><?= $t['active'] ? t('pricing.active') : t('pricing.inactive') ?></span>
|
||||
</td>
|
||||
<td class="text-end"><div class="btn-list justify-content-end">
|
||||
<button class="btn btn-sm btn-outline-primary tariff-edit" type="button"
|
||||
data-id="<?= (int)$t['id'] ?>" data-clinic="<?= (int)$t['clinic_contact_id'] ?>"
|
||||
data-label="<?= h($t['label']) ?>" data-amount="<?= h(number_format($t['amount_cents'] / 100, 2, '.', '')) ?>"
|
||||
data-category="<?= h($t['category']) ?>" data-group="<?= h($t['discount_group']) ?>"
|
||||
data-unit="<?= h($t['unit_label']) ?>" data-medication="<?= (int)($t['medication_id'] ?? 0) ?>"
|
||||
data-active="<?= (int)$t['active'] ?>"><?= h(t('common.edit')) ?></button>
|
||||
<form method="post" action="/settings/pricing/tariff/delete" onsubmit="return confirm(<?= h(json_encode(t('pricing.delete_confirm'), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)) ?>)">
|
||||
<input type="hidden" name="id" value="<?= (int)$t['id'] ?>"><button class="btn btn-sm btn-outline-danger" type="submit"><?= h(t('common.delete')) ?></button>
|
||||
</form>
|
||||
</div></td>
|
||||
</tr><?php endforeach; ?></tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
document.querySelectorAll('.tariff-edit').forEach((button) => button.addEventListener('click', () => {
|
||||
const fields = {tariffId:'id',tariffClinic:'clinic',tariffLabel:'label',tariffAmount:'amount',tariffCategory:'category',tariffGroup:'group',tariffUnit:'unit',tariffMedication:'medication'};
|
||||
Object.entries(fields).forEach(([id, key]) => { document.getElementById(id).value = button.dataset[key] || ''; });
|
||||
document.getElementById('tariffActive').checked = button.dataset.active === '1';
|
||||
document.getElementById('tariffForm').scrollIntoView({behavior:'smooth', block:'start'});
|
||||
document.getElementById('tariffLabel').focus({preventScroll:true});
|
||||
}));
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Reference in a new issue