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

@ -2,6 +2,22 @@
Toutes les modifications importantes du projet sont consignées ici. Le format s’inspire de [Keep a Changelog](https://keepachangelog.com/fr/1.1.0/) et le projet suit le [versionnage sémantique](https://semver.org/lang/fr/).
## [1.0.0-rc.30] — 2026-10-01
### Fiabilisation des dossiers et du suivi médical
- correction de la fausse déclaration de décès de Lucci après vérification ASM3 et protection contre les fiches de décès résiduelles lors d’une correction de statut ;
- réparation de l’actualisation I-CAD après la suppression de l’ancienne adresse `/pro` ;
- exclusion uniforme des animaux adoptés dans les rappels et traitements du tableau de bord ;
- affichage de la date du test FIV/FeLV et possibilité d’en comptabiliser le tarif ;
- ajout direct d’un vaccin depuis sa liste, fabricants suggérés et tri alphabétique ;
- filtrage des tarifs par clinique pour les vaccins, tests et chirurgies ;
- propositions normalisées d’intitulés chirurgicaux et catalogue médical administrable ;
- lien direct entre l’adoptant et sa fiche d’annuaire, ainsi que de nouveaux rôles de professionnels animaliers ;
- amélioration du menu mobile, des zones de texte du site public et des longues listes de rappels ;
- ajout d’un script protégé permettant de réinitialiser automatiquement une instance de démonstration à heure fixe ;
- nouvelle icône Android issue du logo officiel de l’application.
## [1.0.0-rc.29] — 2026-09-22
### Corrections du suivi médical et du site public

View file

@ -10,6 +10,10 @@ L’import depuis Animal Shelter Manager a été conçu comme un parcours pruden
Avant la version 1.0, le projet a fait l’objet d’un nettoyage structurel et d’un découpage de ses fichiers les plus volumineux. La recherche universelle, les salles configurables, les traductions française et anglaise et une suite de contrôles isolés ont complété cette phase de stabilisation.
## `1.0.0-rc.30` — Corrections issues de la validation terrain
Une passe croisée avec les sauvegardes ASM3 a corrigé une collision historique entre Gribouille et Lucci. Le suivi médical gagne une date de test FIV/FeLV, des catalogues administrables et une meilleure association entre tarifs et cliniques. La synchronisation I-CAD, la navigation mobile et l’identité Android ont également été adaptées aux conditions réelles d’utilisation.
## `1.0.0-rc.29` — Suivi médical et présentation
Les traitements et les intitulés des produits médicaux peuvent être corrigés après leur saisie. Le formulaire des vermifuges s’ouvre de nouveau correctement. La fiche animale montre sa date de naissance et le CSS personnalisé du site public prend priorité sur les styles standard.

View file

@ -200,7 +200,7 @@ L’option `--apply` ne doit être utilisée qu’après lecture des rapports. L
## État du projet
La candidate actuelle est `1.0.0-rc.29`. La branche 1.0 est gelée fonctionnellement : seuls les défauts bloquants découverts pendant les validations terrain sont corrigés avant `1.0.0`.
La candidate actuelle est `1.0.0-rc.30`. La branche 1.0 est gelée fonctionnellement : seuls les défauts bloquants découverts pendant les validations terrain sont corrigés avant `1.0.0`.
Le contrôle de stabilisation est disponible dans [docs/AUDIT-1.0.md](docs/AUDIT-1.0.md).

View file

@ -1 +1 @@
1.0.0-rc.29
1.0.0-rc.30

View file

@ -518,7 +518,7 @@ trait AnimalBrowseActions
// Adoptions
$stmt = $db->prepare('
SELECT adopter_name, adopter_address, adopter_postal_code, adopter_city, adopter_country, adopter_phone, adopter_email, adoption_date
SELECT adopter_name, adopter_address, adopter_postal_code, adopter_city, adopter_country, adopter_phone, adopter_email, adoption_date, adopter_contact_id
FROM adoptions
WHERE animal_id = :id
ORDER BY id DESC
@ -650,7 +650,10 @@ trait AnimalBrowseActions
$ref_med_administration = $db
->query('SELECT id, name, accro FROM ref_med_administration ORDER BY id')
->fetchAll();
$vaccines = $db->query('SELECT id, name FROM ref_vaccines ORDER BY id')->fetchAll();
$vaccines = $db->query('SELECT id, name FROM ref_vaccines ORDER BY name COLLATE NOCASE,id')->fetchAll();
$vaccineManufacturers = $db
->query('SELECT id,name FROM ref_vaccine_manufacturers WHERE active=1 ORDER BY name COLLATE NOCASE,id')
->fetchAll(PDO::FETCH_ASSOC);
$inventoryBatches = $db
->query(
'SELECT b.id,b.batch_number,b.expires_on,b.quantity,p.name,p.unit,p.category,p.reference_id FROM inventory_batches b JOIN inventory_products p ON p.id=b.product_id WHERE b.quantity>0 AND p.active=1 ORDER BY p.category,p.name COLLATE NOCASE,date(b.expires_on)',
@ -958,6 +961,7 @@ trait AnimalBrowseActions
'surgeries' => $surgeries,
'ref_med_administration' => $ref_med_administration,
'vaccines' => $vaccines,
'vaccineManufacturers' => $vaccineManufacturers,
'inventoryBatches' => $inventoryBatches,
'activeUsers' => $activeUsers,
'clinics' => $clinics,

View file

@ -32,6 +32,8 @@ trait AnimalMedicalActions
$testDate = date('Y-m-d');
}
$testNotes = trim((string) ($_POST['test_notes'] ?? ''));
$testTariffId = (int) ($_POST['test_tariff_id'] ?? 0);
$testClinicId = (int) ($_POST['clinic_contact_id'] ?? 0);
$conditions = is_array($_POST['conditions'] ?? null) ? $_POST['conditions'] : [];
$db = DB::pdo();
@ -53,6 +55,7 @@ trait AnimalMedicalActions
UPDATE animals
SET fiv_status = :fiv_status,
felv_status = :felv_status,
fiv_felv_test_date = :test_date,
fiv = :fiv,
felv = :felv,
updated_at = datetime('now')
@ -61,6 +64,7 @@ trait AnimalMedicalActions
)->execute([
':fiv_status' => $fivStatus,
':felv_status' => $felvStatus,
':test_date' => $testDate,
':fiv' => $fivStatus === 'pos' ? 1 : 0,
':felv' => $felvStatus === 'pos' ? 1 : 0,
':id' => $animalId,
@ -98,6 +102,15 @@ trait AnimalMedicalActions
}
}
if ($testTariffId > 0) {
$tariffCheck = $db->prepare("SELECT 1 FROM clinic_tariffs WHERE id=? AND clinic_contact_id=? AND category='test' AND active=1");
$tariffCheck->execute([$testTariffId, $testClinicId]);
if (!$testClinicId || !$tariffCheck->fetchColumn()) {
throw new RuntimeException(t('error.tariff_not_found'));
}
PricingService::record($db, $animalId, $testTariffId, 1, $testDate, $testNotes);
}
$conditionSelect = $db->prepare(
'SELECT status FROM animal_health_conditions WHERE id = :id AND animal_id = :animal_id',
);

View file

@ -746,6 +746,18 @@ trait AnimalRecordActions
':current_lng' => $currentLng,
]);
// Un décès est une donnée structurée distincte du statut. Lors d'une correction
// explicite d'un animal déclaré à tort décédé, ne pas laisser une ancienne fiche
// de décès continuer à alimenter la bannière et les statistiques.
$oldWasDeceased = in_array(strtolower((string) ($old['status'] ?? '')), ['decede', 'décédé'], true);
$isNowDeceased = in_array(strtolower($status), ['decede', 'décédé'], true);
if ($oldWasDeceased && !$isNowDeceased) {
$db->prepare('DELETE FROM animal_deaths WHERE animal_id=:id')->execute([':id' => $id]);
$db->prepare(
"INSERT INTO animal_history(animal_id,action,type,label,details,user_id) VALUES(:id,'death_correction','update','Décès annulé','La fiche de décès a été retirée après correction du statut de l’animal.',:user)",
)->execute([':id' => $id, ':user' => Auth::id()]);
}
if ($old) {
LocationHistoryService::record(
$db,

View file

@ -119,7 +119,7 @@ final class DashboardController
JOIN ref_vaccines rv ON rv.id = v.vaccine_id
WHERE v.due_date IS NOT NULL
AND a.deleted_at IS NULL AND a.archived_at IS NULL
AND lower(a.status) NOT IN ('decede','décédé')
AND lower(a.status) NOT IN ('decede','décédé','adopte','adopté')
AND date(v.due_date) < date('now')
ORDER BY date(v.due_date) ASC
LIMIT 50
@ -135,7 +135,7 @@ final class DashboardController
JOIN ref_vaccines rv ON rv.id = v.vaccine_id
WHERE v.due_date IS NOT NULL
AND a.deleted_at IS NULL AND a.archived_at IS NULL
AND lower(a.status) NOT IN ('decede','décédé')
AND lower(a.status) NOT IN ('decede','décédé','adopte','adopté')
AND date(v.due_date) >= date('now')
AND date(v.due_date) <= date('now', '+7 day')
ORDER BY date(v.due_date) ASC
@ -152,7 +152,7 @@ final class DashboardController
JOIN ref_vaccines rv ON rv.id = v.vaccine_id
WHERE v.due_date IS NOT NULL
AND a.deleted_at IS NULL AND a.archived_at IS NULL
AND lower(a.status) NOT IN ('decede','décédé')
AND lower(a.status) NOT IN ('decede','décédé','adopte','adopté')
AND date(v.due_date) > date('now', '+7 day')
AND date(v.due_date) <= date('now', '+30 day')
ORDER BY date(v.due_date) ASC
@ -162,7 +162,7 @@ final class DashboardController
$vaccines_30d = $stmt->fetchAll();
// Traitements en cours
$stmt = $db->prepare('
$stmt = $db->prepare("
SELECT a.id, a.name, a.internal_code AS code,
m.name AS medication_name,
t.start_date, t.end_date, t.dose_text, t.route
@ -171,9 +171,10 @@ final class DashboardController
JOIN ref_medications m ON m.id = t.medication_id
WHERE t.ongoing = 1
AND a.deleted_at IS NULL AND a.archived_at IS NULL
AND lower(a.status) NOT IN ('decede','décédé','adopte','adopté')
ORDER BY date(t.start_date) DESC, a.name ASC
LIMIT 50
');
");
$stmt->execute();
$treatments = $stmt->fetchAll();
@ -185,6 +186,7 @@ final class DashboardController
JOIN ref_medications m ON m.id = t.medication_id
WHERE t.ongoing = 1
AND a.deleted_at IS NULL AND a.archived_at IS NULL
AND lower(a.status) NOT IN ('decede','décédé','adopte','adopté')
AND t.end_date IS NOT NULL
AND date(t.end_date) < date('now')
ORDER BY date(t.end_date) ASC

View file

@ -15,6 +15,10 @@ final class DirectoryController
'dirigeant' => t('role.dirigeant'),
'fa' => t('role.fa'),
'fourriere' => t('role.fourriere'),
'pet_sitter' => t('role.pet_sitter'),
'refuge_partenaire' => t('role.refuge_partenaire'),
'toiletteur' => t('role.toiletteur'),
'professionnel_autre' => t('role.professionnel_autre'),
'veterinaire' => t('role.veterinaire'),
];
}

View file

@ -1227,6 +1227,68 @@ final class SettingsController
header('X-Content-Type-Options: nosniff');
readfile($path);
}
public static function catalogs(): void
{
self::admin();
$db = DB::pdo();
render('settings_catalogs.php', [
'title' => t('settings.catalogs'),
'catalogs' => [
'medication' => $db->query('SELECT id,name,molecule extra FROM ref_medications ORDER BY name COLLATE NOCASE')->fetchAll(PDO::FETCH_ASSOC),
'vaccine' => $db->query('SELECT id,name,code extra FROM ref_vaccines ORDER BY name COLLATE NOCASE')->fetchAll(PDO::FETCH_ASSOC),
'dewormer' => $db->query('SELECT id,name,active_ingredient extra FROM ref_dewormers ORDER BY name COLLATE NOCASE')->fetchAll(PDO::FETCH_ASSOC),
'manufacturer' => $db->query('SELECT id,name,NULL extra FROM ref_vaccine_manufacturers ORDER BY name COLLATE NOCASE')->fetchAll(PDO::FETCH_ASSOC),
],
'saved' => isset($_GET['saved']),
'error' => (string) ($_GET['error'] ?? ''),
]);
}
public static function saveCatalogItem(): void
{
self::admin(); self::postOnly();
$type = (string) ($_POST['type'] ?? '');
$id = (int) ($_POST['id'] ?? 0);
$name = trim((string) ($_POST['name'] ?? ''));
$extra = trim((string) ($_POST['extra'] ?? '')) ?: null;
$map = [
'medication' => ['ref_medications','molecule'], 'vaccine' => ['ref_vaccines','code'],
'dewormer' => ['ref_dewormers','active_ingredient'], 'manufacturer' => ['ref_vaccine_manufacturers',null],
];
if ($name === '' || !isset($map[$type])) {
header('Location: /settings/catalogs?error=' . rawurlencode(t('catalog.invalid'))); exit();
}
[$table,$extraColumn] = $map[$type];
try {
if ($id) {
$sql = "UPDATE $table SET name=?" . ($extraColumn ? ",$extraColumn=?" : '') . ' WHERE id=?';
DB::pdo()->prepare($sql)->execute($extraColumn ? [$name,$extra,$id] : [$name,$id]);
} else {
$sql = "INSERT INTO $table(name" . ($extraColumn ? ",$extraColumn" : '') . ') VALUES(?' . ($extraColumn ? ',?' : '') . ')';
DB::pdo()->prepare($sql)->execute($extraColumn ? [$name,$extra] : [$name]);
$id = (int) DB::pdo()->lastInsertId();
}
AuditService::log('catalog_saved', '/settings/catalogs/save', 'Catalogue modifié : ' . $name, $type, $id);
header('Location: /settings/catalogs?saved=1');
} catch (Throwable $e) {
header('Location: /settings/catalogs?error=' . rawurlencode(SecurityService::publicError($e)));
}
exit();
}
public static function deleteCatalogItem(): void
{
self::admin(); self::postOnly();
$type = (string) ($_POST['type'] ?? ''); $id = (int) ($_POST['id'] ?? 0);
$tables = ['medication'=>'ref_medications','vaccine'=>'ref_vaccines','dewormer'=>'ref_dewormers','manufacturer'=>'ref_vaccine_manufacturers'];
if (!$id || !isset($tables[$type])) { http_response_code(400); return; }
try {
DB::pdo()->prepare('DELETE FROM ' . $tables[$type] . ' WHERE id=?')->execute([$id]);
AuditService::log('catalog_deleted', '/settings/catalogs/delete', 'Élément de catalogue supprimé', $type, $id);
header('Location: /settings/catalogs?saved=1');
} catch (Throwable) {
header('Location: /settings/catalogs?error=' . rawurlencode(t('catalog.in_use')));
}
exit();
}
private static function postOnly(): void
{
if (($_SERVER['REQUEST_METHOD'] ?? 'GET') !== 'POST') {

View file

@ -56,6 +56,16 @@ final class SurgeriesController
}
$db = DB::pdo();
$tariff = (int) ($_POST['tariff_id'] ?? 0) ?: null;
$clinic = (int) ($_POST['clinic_contact_id'] ?? 0) ?: null;
if ($tariff) {
$validTariff = $db->prepare('SELECT 1 FROM clinic_tariffs WHERE id=? AND clinic_contact_id=? AND active=1');
$validTariff->execute([$tariff, $clinic]);
if (!$clinic || !$validTariff->fetchColumn()) {
http_response_code(400);
echo h(t('surgery.invalid_data'));
return;
}
}
$amountRaw = str_replace(',', '.', trim((string) ($_POST['amount'] ?? '')));
$amount = $amountRaw === '' ? null : (int) round(max(0, (float) $amountRaw) * 100);
if ($amount === null && $tariff) {
@ -77,7 +87,7 @@ final class SurgeriesController
$name,
$date,
$status,
(int) ($_POST['clinic_contact_id'] ?? 0) ?: null,
$clinic,
(int) ($_POST['veterinarian_contact_id'] ?? 0) ?: null,
$tariff,
$amount,
@ -92,7 +102,7 @@ final class SurgeriesController
'INSERT INTO animal_expenses(animal_id,clinic_contact_id,tariff_id,source_type,source_id,label,occurred_on,quantity,catalog_unit_cents,discount_percent,total_cents,notes,created_by) VALUES(?,?,?,\'surgery\',?,?,?,1,?,0,?,?,?)',
)->execute([
$animal,
(int) ($_POST['clinic_contact_id'] ?? 0) ?: null,
$clinic,
$tariff,
$id,
$name,

View file

@ -338,6 +338,15 @@ switch ($path) {
case '/settings/pricing':
SettingsController::pricing();
break;
case '/settings/catalogs':
SettingsController::catalogs();
break;
case '/settings/catalogs/save':
SettingsController::saveCatalogItem();
break;
case '/settings/catalogs/delete':
SettingsController::deleteCatalogItem();
break;
case '/settings/pricing/tariff':
SettingsController::saveTariff();
break;

View file

@ -112,8 +112,19 @@ final class IcadService
]);
$this->assertSuccess($r2, t('service.icad.login_failed'));
// Le point d'entrée renvoie désormais du JSON et fournit l'adresse réelle
// de l'espace connecté. L'ancienne URL fixe /pro répond en 404 depuis 2026.
$loginResponse = json_decode(trim((string) $r2['body']), true);
if (is_array($loginResponse) && trim((string) ($loginResponse['error'] ?? '')) !== '') {
throw new RuntimeException(t('service.icad.login_failed'));
}
$accountPath = is_array($loginResponse) ? trim((string) ($loginResponse['address'] ?? '')) : '';
if ($accountPath === '' || !str_starts_with($accountPath, '/')) {
$accountPath = '/acteur';
}
// 3) Vérif session
$r2b = $this->req('https://www.i-cad.fr/pro', $cookie);
$r2b = $this->req('https://www.i-cad.fr' . $accountPath, $cookie);
$this->assertSuccess($r2b, t('service.icad.login_failed'));
if (stripos($r2b['body'], 'Se connecter') !== false || str_contains((string)$r2b['effective_url'], '/login')) {
throw new RuntimeException(t('service.icad.login_failed'));

View file

@ -20,14 +20,14 @@ final class NotificationService
'treatments',
'danger',
t('notification.treatments_overdue'),
"SELECT COUNT(*) FROM treatments t JOIN animals a ON a.id=t.animal_id WHERE t.ongoing=1 AND t.end_date IS NOT NULL AND date(t.end_date)<date('now') AND a.deleted_at IS NULL AND a.archived_at IS NULL",
"SELECT COUNT(*) FROM treatments t JOIN animals a ON a.id=t.animal_id WHERE t.ongoing=1 AND t.end_date IS NOT NULL AND date(t.end_date)<date('now') AND a.deleted_at IS NULL AND a.archived_at IS NULL AND lower(a.status) NOT IN ('decede','décédé','adopte','adopté')",
'/dashboard#active-treatments',
],
[
'dewormings',
'warning',
t('notification.dewormings_due'),
"SELECT COUNT(*) FROM dewormings d JOIN animals a ON a.id=d.animal_id WHERE d.next_due_date IS NOT NULL AND date(d.next_due_date)<=date('now','+7 day') AND a.deleted_at IS NULL AND a.archived_at IS NULL AND NOT EXISTS(SELECT 1 FROM dewormings newer WHERE newer.animal_id=d.animal_id AND date(newer.administered_on)>date(d.administered_on))",
"SELECT COUNT(*) FROM dewormings d JOIN animals a ON a.id=d.animal_id WHERE d.next_due_date IS NOT NULL AND date(d.next_due_date)<=date('now','+7 day') AND a.deleted_at IS NULL AND a.archived_at IS NULL AND lower(a.status) NOT IN ('decede','décédé','adopte','adopté') AND NOT EXISTS(SELECT 1 FROM dewormings newer WHERE newer.animal_id=d.animal_id AND date(newer.administered_on)>date(d.administered_on))",
'/dashboard',
],
];

View file

@ -4,7 +4,7 @@
<!-- IDENTITÉ -->
<div class="tab-pane active show" id="tab-ident">
<?php if ($canViewMedical && !empty($death)): ?>
<?php if ($canViewMedical && !empty($death) && in_array(strtolower((string)$animal['status']), ['decede','décédé'], true)): ?>
<?php
$deathCauseLabels = array_combine(array_keys(DeathController::CAUSES), array_map(static fn ($key) => DeathController::causeLabel($key), array_keys(DeathController::CAUSES)));
$deathPlaceLabels = array_combine(array_keys(DeathController::PLACES), array_map(static fn ($key) => DeathController::placeLabel($key), array_keys(DeathController::PLACES)));
@ -221,11 +221,15 @@ $hasCurrent = ($currentLat !== null && $currentLng !== null);
</div>
<?php if ($animal['status'] === 'adopte'): ?>
<?php if (in_array($animal['status'], ['adopte','adopté'], true) && !empty($adoption)): ?>
<div class="alert alert-success mt-3">
<strong><?= h(t('animal.adopted_by')) ?> :</strong><br>
<?= htmlspecialchars($adoption['adopter_name'] . ' - ' . $adoption['adopter_address'] . ' ' . $adoption['adopter_postal_code'] . ' ' . $adoption['adopter_city'] . ' - (' . $adoption['adopter_phone'] . ' - ' . $adoption['adopter_email'] . ')') ?>
<?php if (!empty($adoption['adopter_contact_id'])): ?><a class="fw-bold" href="/directory/show?id=<?= (int)$adoption['adopter_contact_id'] ?>"><?= h($adoption['adopter_name']) ?></a><?php else: ?><span class="fw-bold"><?= h($adoption['adopter_name']) ?></span><?php endif; ?>
<div class="small mt-1"><?= h(trim(implode(' · ', array_filter([
trim((string)($adoption['adopter_address'] ?? '') . ' ' . (string)($adoption['adopter_postal_code'] ?? '') . ' ' . (string)($adoption['adopter_city'] ?? '')),
$adoption['adopter_phone'] ?? '', $adoption['adopter_email'] ?? ''
])))) ?></div>
</div>
<?php endif; ?>

View file

@ -22,6 +22,10 @@
<div class="col-12 col-md-3">
<div class="subheader mb-1">FeLV</div>
<span class="badge <?= $felvClass ?>"><?= h($felvLabel) ?></span>
</div>
<div class="col-12 col-md-3">
<div class="subheader mb-1"><?= h(t('animal.test_date')) ?></div>
<strong><?= !empty($animal['fiv_felv_test_date']) ? h(date('d/m/Y', strtotime((string)$animal['fiv_felv_test_date']))) : '—' ?></strong>
</div><?php endif; ?>
<div class="col-12 <?= $isCat ? 'col-md-6' : '' ?>">
<div class="subheader mb-1"><?= h(t('animal.conditions_short')) ?></div>
@ -423,6 +427,9 @@ ORDER BY created_at ASC
<!-- VACCINS -->
<div class="tab-pane" id="tab-vac">
<div class="d-flex justify-content-end mb-3">
<button class="btn btn-primary" type="button" data-bs-toggle="modal" data-bs-target="#modalVaccine">+ <?= h(t('animal.add_vaccine')) ?></button>
</div>
<?php if (!$vaccinations): ?>
<div class="text-muted"><?= h(t('animal.no_vaccine_recorded')) ?></div>
<?php else: ?>

View file

@ -300,7 +300,11 @@ $currentTime = date('H:i');
<div class="col-md-4">
<label class="form-label"><?= h(t('animal.manufacturer')) ?></label>
<input class="form-control" name="manufacturer" placeholder="Ex : Boehringer Ingelheim">
<input class="form-control" name="manufacturer" list="vaccineManufacturerList"
placeholder="Ex : Boehringer Ingelheim">
<datalist id="vaccineManufacturerList">
<?php foreach (($vaccineManufacturers ?? []) as $manufacturer): ?><option value="<?= h($manufacturer['name']) ?>"></option><?php endforeach; ?>
</datalist>
</div>
<div class="col-md-4">
@ -619,13 +623,29 @@ document.addEventListener('DOMContentLoaded', () => {
</div>
<div class="col-md-4">
<label class="form-label"><?= h(t('animal.test_date')) ?></label>
<input class="form-control" type="date" name="test_date" value="<?= date('Y-m-d') ?>">
<input class="form-control" type="date" name="test_date"
value="<?= h($animal['fiv_felv_test_date'] ?: date('Y-m-d')) ?>">
</div>
<div class="col-md-8">
<label class="form-label"><?= h(t('animal.test_note')) ?></label>
<input class="form-control" name="test_notes"
placeholder="<?= h(t('animal.test_notes_placeholder')) ?>">
</div>
<div class="col-md-6">
<label class="form-label"><?= h(t('animal.veterinary_clinic')) ?></label>
<select class="form-select" name="clinic_contact_id">
<option value="">— <?= h(t('common.choose')) ?> —</option>
<?php foreach (($directoryClinics ?? []) as $clinic): ?><option value="<?= (int)$clinic['id'] ?>"><?= h($clinic['name']) ?></option><?php endforeach; ?>
</select>
</div>
<div class="col-md-6">
<label class="form-label"><?= h(t('animal.tariff_record')) ?> <span class="text-muted">(<?= h(mb_strtolower(t('common.optional'))) ?>)</span></label>
<select class="form-select" name="test_tariff_id">
<option value=""><?= h(t('animal.no_expense')) ?></option>
<?php foreach (($expenseTariffs ?? []) as $tariff): if (($tariff['category'] ?? '') !== 'test') continue; ?><option
value="<?= (int)$tariff['id'] ?>" data-clinic="<?= (int)$tariff['clinic_contact_id'] ?>"><?= h($tariff['clinic_name'] . ' · ' . $tariff['label']) ?> · <?= number_format((int)$tariff['effective_cents']/100, 2, ',', ' ') ?> €</option><?php endforeach; ?>
</select>
</div>
</div>
<hr class="my-4">
@ -694,6 +714,22 @@ document.addEventListener('DOMContentLoaded', () => {
</form>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
const modal = document.getElementById('modalMedicalStatus');
const clinic = modal?.querySelector('select[name="clinic_contact_id"]');
const tariff = modal?.querySelector('select[name="test_tariff_id"]');
const sync = () => {
[...(tariff?.options || [])].forEach(option => {
if (!option.dataset.clinic) return;
option.hidden = !clinic?.value || option.dataset.clinic !== clinic.value;
option.disabled = option.hidden;
});
if (tariff?.selectedOptions[0]?.hidden) tariff.value = '';
};
clinic?.addEventListener('change', sync); sync();
});
</script>
<div class="modal modal-blur fade" id="modalMedical" tabindex="-1" aria-hidden="true">
<div class="modal-dialog modal-lg modal-dialog-centered" role="document">

View file

@ -5,7 +5,7 @@
foreach (($expenseTariffs ?? []) as $t):if ($expenseClinic !== $t['clinic_name']):if ($expenseClinic !== ''):?>
</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>

View file

@ -16,6 +16,7 @@ if (!function_exists('settingsNavigationLinks')) {
'rooms' => ['/settings/rooms','🚪',t('settings.rooms'),'business'],
'pricing' => ['/settings/pricing','💶',t('settings.pricing'),'business'],
'inventory' => ['/settings/inventory','💊',t('settings.inventory'),'business'],
'catalogs' => ['/settings/catalogs','📚',t('settings.catalogs'),'business'],
'lab-references' => ['/settings/lab-references','🩸',t('settings.lab_references'),'business'],
'users' => ['/settings/users','👥',t('settings.users'),'access'],
'permissions' => ['/settings/permissions','🔐',t('settings.permissions'),'access'],

View file

@ -27,7 +27,8 @@
<div class="mb-3">
<label class="form-label"><?= h(t('adoption.adopter_name')) ?></label>
<input type="text" name="adopter_name" id="adopterName" class="form-control" required>
<input type="text" name="adopter_name" id="adopterName" class="form-control"
placeholder="Prénom NOM" required>
</div>
<div class="mb-3">

Some files were not shown because too many files have changed in this diff Show more