Configure les tarifs d'adoption par espèce

Refs #14 #18
This commit is contained in:
Alexandre NOEL 2026-09-08 00:44:40 +02:00
commit 1378aefa9c
14 changed files with 93 additions and 35 deletions

View file

@ -641,7 +641,7 @@ $today = date('Y-m-d');
<span class="form-check-label">
<span class="fw-bold d-block"><?= h(t('animal.sterilization_act')) ?></span>
<span
class="form-hint mt-0"><?= h(!empty($animal['sterilized']) ? t('animal.already_sterilized') : t('animal.sterilization_auto', ['price' => AppSettings::int('adoption_fee_sterilized')])) ?></span>
class="form-hint mt-0"><?php $feeAfterSterilization = PricingService::adoptionFee((string)$animal['species'], true); ?><?= h(!empty($animal['sterilized']) ? t('animal.already_sterilized') : ($feeAfterSterilization === null ? t('animal.sterilization_auto_free') : t('animal.sterilization_auto', ['price' => $feeAfterSterilization]))) ?></span>
</span>
</label>
</div>

View file

@ -285,9 +285,9 @@ if ($felvPos) {
<span class="badge <?= h($sterilizationClass) ?>">
<?= h($sterilizationLabel) ?>
</span>
<?php if ($isCat): ?><span class="text-muted small"><?= h(t('animal.adoption_fee_hint')) ?>
<strong
class="text-body"><?= $sterilizationState === 'yes' ? AppSettings::int('adoption_fee_sterilized') . ' €' : AppSettings::int('adoption_fee_unsterilized') . ' €' ?></strong></span><?php endif; ?>
<?php $adoptionFee = PricingService::adoptionFee((string)$animal['species'], $sterilizationState === 'yes'); ?>
<span class="text-muted small"><?= h(t('animal.adoption_fee_hint')) ?>
<strong class="text-body"><?= $adoptionFee === null ? h(t('pricing.free_fee')) : $adoptionFee . ' €' ?></strong></span>
<?php if ($sterilizationState === 'yes' && (!empty($animal['sterilization_date']) || !empty($sterilizationContacts))): ?><span
class="text-muted small"><?= !empty($animal['sterilization_date']) ? h(date('d/m/Y', strtotime((string)$animal['sterilization_date']))) : '' ?><?= !empty($sterilizationContacts['vet']['name']) ? ' · ' . h($sterilizationContacts['vet']['name']) : '' ?><?= !empty($sterilizationContacts['clinic']['name']) ? ' · ' . h($sterilizationContacts['clinic']['name']) : '' ?></span><?php endif; ?>
</div>

View file

@ -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.11</span>
<h3>Salles et tournées configurables</h3>
<p class="text-muted">Critères d’accueil par salle et créneaux de soins adaptés à l’organisation du refuge.</p>
<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>
</div>
</section>
</div>

View file

@ -6,7 +6,7 @@
<?php if ($saved): ?><div class="alert alert-success">✅ <?= h(t('pricing.saved')) ?></div>
<?php endif; ?><?php if ($error !== ''): ?><div class="alert alert-danger"><?= h($error) ?></div><?php endif; ?>
<div class="row row-cards mb-4">
<div class="col-lg-5">
<div class="col-lg-7">
<form class="card h-100" method="post" action="/settings/pricing/adoption">
<div class="card-status-top bg-green"></div>
<div class="card-header">
@ -15,24 +15,19 @@
<div class="text-muted small"><?= h(t('pricing.adoption_fees_help')) ?></div>
</div>
</div>
<div class="card-body row g-3">
<div class="col-6"><label class="form-label"><?= h(t('pricing.sterilized')) ?></label>
<div class="input-group"><input class="form-control" type="number" min="0"
name="adoption_fee_sterilized"
value="<?= (int)$settings['adoption_fee_sterilized'] ?>"><span
class="input-group-text">€</span></div>
</div>
<div class="col-6"><label class="form-label"><?= h(t('pricing.unsterilized')) ?></label>
<div class="input-group"><input class="form-control" type="number" min="0"
name="adoption_fee_unsterilized"
value="<?= (int)$settings['adoption_fee_unsterilized'] ?>"><span
class="input-group-text">€</span></div>
</div>
<div class="table-responsive">
<table class="table table-vcenter mb-0"><thead><tr><th><?= h(t('animal.species')) ?></th><th><?= h(t('pricing.before_sterilization')) ?></th><th><?= h(t('pricing.after_sterilization')) ?></th><th><?= h(t('pricing.free_fee')) ?></th></tr></thead><tbody>
<?php foreach ($adoptionFees as $species => $fee): ?><tr><td class="fw-semibold"><?= h(($fee['icon'] ?? '') . ' ' . $fee['name']) ?></td>
<td><div class="input-group"><input class="form-control" type="number" min="0" max="2000" name="fees[<?= h($species) ?>][before]" value="<?= (int)$fee['fee_before_sterilization'] ?>"><span class="input-group-text">€</span></div></td>
<td><div class="input-group"><input class="form-control" type="number" min="0" max="2000" name="fees[<?= h($species) ?>][after]" value="<?= (int)$fee['fee_after_sterilization'] ?>"><span class="input-group-text">€</span></div></td>
<td><label class="form-check form-switch"><input class="form-check-input adoption-fee-free" type="checkbox" name="fees[<?= h($species) ?>][free]" <?= (int)$fee['is_free'] === 1 ? 'checked' : '' ?>><span class="form-check-label"><?= h(t('pricing.free')) ?></span></label></td>
</tr><?php endforeach; ?>
</tbody></table>
</div>
<div class="card-footer text-end"><button class="btn btn-primary"><?= h(t('common.save')) ?></button></div>
</form>
</div>
<div class="col-lg-7">
<div class="col-lg-5">
<div class="card h-100">
<div class="card-status-top bg-orange"></div>
<div class="card-header">