fix: corriger le suivi médical et les styles publics
This commit is contained in:
parent
f20d7cc965
commit
a55d27935f
15 changed files with 206 additions and 24 deletions
|
|
@ -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">
|
||||
|
|
|
|||
Loading…
Reference in a new issue