fix: corriger le suivi médical et les styles publics

This commit is contained in:
Alexandre NOEL 2026-09-22 18:05:38 +02:00
commit a55d27935f
15 changed files with 206 additions and 24 deletions

View file

@ -198,7 +198,7 @@
<div class="card mt-3">
<div class="card-header d-flex align-items-center justify-content-between">
<div>
<h3 class="card-title m-0"><?= h(t('animals.dewormer')) ?></h3>
<h3 class="card-title m-0">🪱 <?= h(t('animals.dewormer')) ?></h3>
<div class="text-muted small"><?= h(t('animal.deworming_schedule')) ?></div>
</div><button class="btn btn-sm btn-outline-primary" data-bs-toggle="modal"
data-bs-target="#modalDeworming"><?= h(t('common.add')) ?></button>
@ -400,7 +400,19 @@ ORDER BY created_at ASC
<td><?= h($t['start_date']) ?></td>
<td><?= $t['end_date'] ? h($t['end_date']) : '—' ?></td>
<td><?= $t['notes'] ? h($t['notes']) : '—' ?></td>
<td class="text-end"><button type="button" class="btn btn-sm btn-ghost-primary edit-treatment"
data-bs-toggle="modal" data-bs-target="#modalTreatment"
data-entry-id="<?= (int)$t['id'] ?>"
data-medication-id="<?= (int)$t['medication_id'] ?>"
data-route="<?= h($t['route'] ?? '') ?>" data-dose-text="<?= h($t['dose_text']) ?>"
data-start-date="<?= h($t['start_date']) ?>" data-end-date="<?= h($t['end_date'] ?? '') ?>"
data-clinic-contact-id="<?= (int)($t['clinic_contact_id'] ?? 0) ?>"
data-vet-contact-id="<?= (int)($t['vet_contact_id'] ?? 0) ?>"
data-give-morning="<?= (int)$t['give_morning'] ?>"
data-give-evening="<?= (int)$t['give_evening'] ?>"
data-give-as-needed="<?= (int)$t['give_as_needed'] ?>"
data-notes="<?= h($t['notes'] ?? '') ?>"
aria-label="<?= h(t('common.edit')) ?>">✏️</button></td>
</tr>
<?php endforeach; ?>
</tbody>

View file

@ -22,6 +22,7 @@ $currentTime = date('H:i');
<div class="modal-body">
<input type="hidden" name="animal_id" value="<?= (int)$animal['id'] ?>">
<input type="hidden" name="entry_id" value="">
<div class="row g-2">
<div class="col-md-8">
@ -37,6 +38,8 @@ $currentTime = date('H:i');
<button class="btn btn-outline-primary" type="button" id="treatmentMedicationAdd"
aria-expanded="false" aria-controls="treatmentMedicationNew">+
<?= h(t('common.add')) ?></button>
<button class="btn btn-outline-secondary" type="button" data-bs-toggle="modal"
data-bs-target="#modalProductRename">✏️</button>
</div>
</div>
<div class="col-md-4">
@ -105,7 +108,7 @@ $currentTime = date('H:i');
<?php $directoryFieldId = 'treatment';
require __DIR__ . '/_directory_medical_fields.php'; ?>
<?php require __DIR__ . '/_expense_tariff_field.php'; ?>
<div data-treatment-new-only style="display: contents"><?php require __DIR__ . '/_expense_tariff_field.php'; ?></div>
<div class="col-12">
<label class="form-label"><?= h(t('common.notes')) ?></label>
@ -166,7 +169,8 @@ $currentTime = date('H:i');
<option value=""><?= h(t('common.not_provided')) ?></option>
<?php foreach ($dewormers as $m): ?><option value="<?= (int)$m['id'] ?>">
<?= h($m['name']) ?></option><?php endforeach; ?>
</select></div>
</select><button class="btn btn-sm btn-link px-0" type="button" data-bs-toggle="modal"
data-bs-target="#modalProductRename"><?= h(t('catalog.rename')) ?></button></div>
<div class="col-md-6"><label class="form-label"><?= h(t('animal.dose')) ?></label><input
class="form-control" name="dose_text" placeholder="<?= h(t('deworm.dose_example')) ?>">
</div>
@ -269,7 +273,8 @@ $currentTime = date('H:i');
<option value="<?= (int)$v['id'] ?>"><?= htmlspecialchars($v['name'], ENT_QUOTES) ?>
</option>
<?php endforeach; ?>
</select>
</select><button class="btn btn-sm btn-link px-0" type="button" data-bs-toggle="modal"
data-bs-target="#modalProductRename"><?= h(t('catalog.rename')) ?></button>
</div>
@ -332,6 +337,33 @@ $currentTime = date('H:i');
<script>
document.addEventListener('DOMContentLoaded', () => {
const treatmentModal = document.getElementById('modalTreatment');
treatmentModal?.addEventListener('show.bs.modal', event => {
const form = treatmentModal.querySelector('form');
const trigger = event.relatedTarget;
const editing = trigger?.classList.contains('edit-treatment') ?? false;
if (!form) return;
form.reset();
form.elements.entry_id.value = editing ? trigger.dataset.entryId : '';
if (editing) {
for (const name of ['medication_id', 'route', 'dose_text', 'start_date', 'end_date',
'clinic_contact_id', 'vet_contact_id', 'notes']) {
const key = name.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
if (form.elements[name]) form.elements[name].value = trigger.dataset[key] || '';
}
for (const name of ['give_morning', 'give_evening', 'give_as_needed']) {
const key = name.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
form.elements[name].checked = trigger.dataset[key] === '1';
}
}
treatmentModal.querySelectorAll('[data-treatment-new-only]').forEach(element => {
element.classList.toggle('d-none', editing);
element.querySelectorAll('input,select,textarea').forEach(input => input.disabled = editing);
});
treatmentModal.querySelectorAll('.directory-contact-select').forEach(select => {
select.dispatchEvent(new Event('change', {bubbles: true}));
});
});
const prepareEditor = (modalId, triggerClass, fields) => {
const modal = document.getElementById(modalId);
if (!modal) return;
@ -371,6 +403,52 @@ document.addEventListener('DOMContentLoaded', () => {
});
</script>
<div class="modal modal-blur fade" id="modalProductRename" tabindex="-1" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<form class="modal-content" method="post" action="/animal/product/rename">
<div class="modal-header"><h5 class="modal-title"><?= h(t('catalog.rename')) ?></h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="<?= h(t('common.close')) ?>"></button></div>
<div class="modal-body">
<input type="hidden" name="animal_id" value="<?= (int)$animal['id'] ?>">
<p class="text-muted small"><?= h(t('catalog.rename_hint')) ?></p>
<label class="form-label"><?= h(t('animal.product')) ?></label>
<select class="form-select mb-3" id="catalogRenameChoice" required>
<option value="">—</option>
<optgroup label="<?= h(t('animal.medication')) ?>">
<?php foreach ($medications as $product): ?><option value="medication:<?= (int)$product['id'] ?>"
data-name="<?= h($product['name']) ?>"><?= h($product['name']) ?></option><?php endforeach; ?>
</optgroup>
<optgroup label="<?= h(t('animals.dewormer')) ?>">
<?php foreach ($dewormers as $product): ?><option value="dewormer:<?= (int)$product['id'] ?>"
data-name="<?= h($product['name']) ?>"><?= h($product['name']) ?></option><?php endforeach; ?>
</optgroup>
<optgroup label="<?= h(t('animal.vaccine')) ?>">
<?php foreach ($vaccines as $product): ?><option value="vaccine:<?= (int)$product['id'] ?>"
data-name="<?= h($product['name']) ?>"><?= h($product['name']) ?></option><?php endforeach; ?>
</optgroup>
</select>
<input type="hidden" name="category" id="catalogRenameCategory">
<input type="hidden" name="product_id" id="catalogRenameId">
<label class="form-label"><?= h(t('common.name')) ?></label>
<input class="form-control" name="name" id="catalogRenameName" maxlength="150" required>
</div>
<div class="modal-footer"><button type="button" class="btn me-auto" data-bs-dismiss="modal"><?= h(t('common.cancel')) ?></button>
<button type="submit" class="btn btn-primary"><?= h(t('common.save')) ?></button></div>
</form>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
const choice = document.getElementById('catalogRenameChoice');
choice?.addEventListener('change', () => {
const [category, id] = choice.value.split(':');
document.getElementById('catalogRenameCategory').value = category || '';
document.getElementById('catalogRenameId').value = id || '';
document.getElementById('catalogRenameName').value = choice.selectedOptions[0]?.dataset.name || '';
});
});
</script>
<div class="modal modal-blur fade" id="modalPrescription" tabindex="-1" aria-hidden="true">
<div class="modal-dialog modal-lg modal-dialog-centered">
<form class="modal-content" method="post" action="/animal/prescription/save" enctype="multipart/form-data">

View file

@ -57,8 +57,6 @@
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
document.querySelectorAll('[data-bs-target="#modalDeworming"]').forEach(b => b.setAttribute(
'data-bs-target', '#modalDewormingCatalog'));
const t = document.getElementById('dewormerNewToggle'),
p = document.getElementById('dewormerNewFields');
t?.addEventListener('change', () => p?.classList.toggle('d-none', !t.checked));

View file

@ -183,6 +183,8 @@ if ($felvPos) {
</div>
<?php endif; ?>
<div class="text-muted mt-1" style="font-size:.7rem"><?= h($animal['internal_code']) ?></div>
<div class="text-muted small mt-1"><?= h(t('animal.form.birth_date')) ?> :
<?= !empty($animal['birth_date']) ? h(date('d/m/Y', strtotime((string)$animal['birth_date']))) : '—' ?></div>
</div>
<div>

View file

@ -99,10 +99,6 @@ if (!function_exists('public_age')) {
--line: #eadfd5
}
<?php if ($theme === 'custom' && trim((string)($settings['public_site_custom_css'] ?? '')) !== ''): ?>
<?= $settings['public_site_custom_css'] ?>
<?php endif; ?>
* {
box-sizing: border-box
}
@ -476,6 +472,9 @@ if (!function_exists('public_age')) {
}
</style>
<?php if ($theme === 'custom' && trim((string)($settings['public_site_custom_css'] ?? '')) !== ''): ?>
<style id="public-site-custom-css"><?= $settings['public_site_custom_css'] ?></style>
<?php endif; ?>
</head>
<body>