Corriger les dossiers animaux et le suivi médical

This commit is contained in:
Alexandre NOEL 2026-10-01 15:22:09 +02:00
commit 7b89fd5dfa
34 changed files with 440 additions and 39 deletions

View file

@ -3,9 +3,9 @@
name="tariff_id">
<option value=""><?= h(t('animal.no_expense')) ?></option><?php $expenseClinic = '';
foreach (($expenseTariffs ?? []) as $t):if ($expenseClinic !== $t['clinic_name']):if ($expenseClinic !== ''):?>
</optgroup><?php endif;
</optgroup><?php endif;
$expenseClinic = $t['clinic_name'];?><optgroup label="<?= h($expenseClinic) ?>"><?php endif;?><option
value="<?= (int)$t['id'] ?>"><?= h($t['label']) ?> ·
value="<?= (int)$t['id'] ?>" data-clinic="<?= (int)$t['clinic_contact_id'] ?>"><?= h($t['label']) ?> ·
<?= number_format($t['effective_cents'] / 100, 2, ',', ' ') ?> €
<?= h(t('animal.net')) ?><?= (float)$t['discount_percent'] > 0 ? ' (−' . number_format((float)$t['discount_percent'], 0) . ' %)' : '' ?>
</option><?php endforeach;
@ -13,3 +13,27 @@ if ($expenseClinic !== ''):?></optgroup><?php endif;?>
</select>
<div class="form-hint"><?= h(t('animal.expense_hint')) ?></div>
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
document.querySelectorAll('form').forEach(form => {
const clinic = form.querySelector('select[name="clinic_contact_id"]');
const tariff = form.querySelector('select[name="tariff_id"]');
if (!clinic || !tariff || tariff.dataset.clinicFilterReady) return;
tariff.dataset.clinicFilterReady = '1';
const sync = () => {
const clinicId = clinic.value;
[...tariff.options].forEach(option => {
if (!option.dataset.clinic) return;
option.hidden = !clinicId || option.dataset.clinic !== clinicId;
option.disabled = option.hidden;
});
[...tariff.querySelectorAll('optgroup')].forEach(group => {
group.hidden = ![...group.querySelectorAll('option')].some(option => !option.hidden);
});
if (tariff.selectedOptions[0]?.hidden) tariff.value = '';
};
clinic.addEventListener('change', sync);
sync();
});
});
</script>