fix: traiter le premier lot de tickets
Refs #4 #5 #6 #9 #12 #16 #18 #20
This commit is contained in:
parent
3f82acbbd8
commit
04cbe54dd1
14 changed files with 87 additions and 12 deletions
|
|
@ -266,6 +266,11 @@ final class SettingsController
|
|||
$color = preg_match('/^#[0-9a-fA-F]{6}$/', (string) ($new['color'] ?? ''))
|
||||
? (string) $new['color']
|
||||
: '#6c757d';
|
||||
$duplicate = $db->prepare('SELECT 1 FROM shelter_rooms WHERE code=? OR name=? COLLATE NOCASE');
|
||||
$duplicate->execute([$code, $newName]);
|
||||
if ($duplicate->fetchColumn()) {
|
||||
throw new RuntimeException(t('rooms.duplicate'));
|
||||
}
|
||||
$db->prepare(
|
||||
'INSERT INTO shelter_rooms(code,name,room_type,status_code,color,bulk_validation,sort_order) VALUES(?,?,?,?,?,?,?)',
|
||||
)->execute([$code, $newName, $type, $status, $color, isset($new['bulk_validation']) ? 1 : 0, 100]);
|
||||
|
|
@ -351,6 +356,13 @@ final class SettingsController
|
|||
exit();
|
||||
}
|
||||
try {
|
||||
$duplicate = $db->prepare(
|
||||
'SELECT 1 FROM ref_species WHERE id<>:id AND (code=:code OR name=:name COLLATE NOCASE)',
|
||||
);
|
||||
$duplicate->execute([':id' => $id, ':code' => $code, ':name' => $name]);
|
||||
if ($duplicate->fetchColumn()) {
|
||||
throw new RuntimeException(t('settings.species_duplicate'));
|
||||
}
|
||||
if ($id > 0) {
|
||||
$old = $db->prepare('SELECT code,is_system FROM ref_species WHERE id=:id');
|
||||
$old->execute([':id' => $id]);
|
||||
|
|
|
|||
|
|
@ -375,6 +375,16 @@ final class DemoDataService
|
|||
$animalIds[$name] = (int) $db->lastInsertId();
|
||||
}
|
||||
|
||||
$publish = $db->prepare(
|
||||
"UPDATE animals SET website_published=1,website_description=? WHERE id=? AND adoption_availability='available'",
|
||||
);
|
||||
foreach (['Moka', 'Pixel', 'Caramel', 'Plume', 'Lune', 'Soleil'] as $name) {
|
||||
$publish->execute([
|
||||
'Fiche fictive publiée pour découvrir le fonctionnement du site public de démonstration.',
|
||||
$animalIds[$name],
|
||||
]);
|
||||
}
|
||||
|
||||
$db->prepare('INSERT INTO litters(mother_id,birth_date,notes) VALUES(?,?,?)')->execute([
|
||||
$animalIds['Plume'],
|
||||
$animals[6][3],
|
||||
|
|
|
|||
|
|
@ -9,7 +9,12 @@ final class GeoService
|
|||
return null;
|
||||
}
|
||||
|
||||
// Cache DB
|
||||
// Garde-fou pour les bases anciennes dans lesquelles la table de cache
|
||||
// n'avait jamais été créée par une migration dédiée.
|
||||
$db->exec(
|
||||
"CREATE TABLE IF NOT EXISTS geocode_cache (q TEXT PRIMARY KEY, lat REAL, lng REAL, raw_json TEXT, fetched_at TEXT NOT NULL DEFAULT (datetime('now')))",
|
||||
);
|
||||
|
||||
$st = $db->prepare('SELECT lat,lng FROM geocode_cache WHERE q=:q LIMIT 1');
|
||||
$st->execute([':q' => $q]);
|
||||
$row = $st->fetch(PDO::FETCH_ASSOC);
|
||||
|
|
@ -17,7 +22,6 @@ final class GeoService
|
|||
return ['lat' => (float) $row['lat'], 'lng' => (float) $row['lng']];
|
||||
}
|
||||
|
||||
// Nominatim (OpenStreetMap) — respecter l'usage: User-Agent + requêtes raisonnables
|
||||
$url = 'https://nominatim.openstreetmap.org/search?format=jsonv2&limit=1&q=' . rawurlencode($q);
|
||||
|
||||
$ch = curl_init($url);
|
||||
|
|
@ -43,7 +47,6 @@ final class GeoService
|
|||
|
||||
$json = json_decode($body, true);
|
||||
if (!is_array($json) || empty($json[0]['lat']) || empty($json[0]['lon'])) {
|
||||
// Stocker "vide" en cache évite de spammer
|
||||
$db->prepare(
|
||||
"INSERT OR REPLACE INTO geocode_cache(q,lat,lng,raw_json,fetched_at) VALUES(:q,NULL,NULL,:raw,datetime('now'))",
|
||||
)->execute([':q' => $q, ':raw' => $body]);
|
||||
|
|
|
|||
|
|
@ -186,6 +186,7 @@
|
|||
|
||||
function frenchMessage(field) {
|
||||
if (field.validity.valueMissing) return <?= json_encode(t('auth.required'), JSON_UNESCAPED_UNICODE) ?> ;
|
||||
if (field.validity.typeMismatch) return <?= json_encode(t('settings.invalid_email'), JSON_UNESCAPED_UNICODE) ?> ;
|
||||
if (field.validity.tooShort) return <?= json_encode(t('auth.password_min', ['count' => '__COUNT__']),
|
||||
JSON_UNESCAPED_UNICODE) ?> .replace('__COUNT__', field.minLength);
|
||||
if (field.validity.patternMismatch) return <?= json_encode(t('auth.invalid_format'),
|
||||
|
|
|
|||
|
|
@ -134,6 +134,17 @@ $fieldOptions = [
|
|||
border-color: #206bc4
|
||||
}
|
||||
|
||||
.care-treatment-choice:has(input:checked) {
|
||||
color: #fff;
|
||||
border-color: var(--tblr-primary);
|
||||
background: var(--tblr-primary)
|
||||
}
|
||||
|
||||
.care-treatment-choice.btn-outline-danger:has(input:checked) {
|
||||
border-color: var(--tblr-danger);
|
||||
background: var(--tblr-danger)
|
||||
}
|
||||
|
||||
@media(max-width:800px) {
|
||||
.care-box {
|
||||
grid-column: span 6 !important
|
||||
|
|
@ -341,12 +352,12 @@ $fieldOptions = [
|
|||
class="card card-sm bg-purple-lt mb-2">
|
||||
<div class="card-body py-2"><strong>💊 <?= h($t['medication_name']) ?></strong>
|
||||
<div class="small mb-2"><?= h($t['dose_text']) ?></div>
|
||||
<div class="btn-group w-100"><label class="btn btn-outline-success"><input
|
||||
<div class="btn-group w-100"><label class="btn btn-outline-success care-treatment-choice"><input
|
||||
type="radio" class="btn-check" name="treatments[<?= (int)$t['id'] ?>]"
|
||||
value="given"
|
||||
<?= ($administrations[(int)$t['id']] ?? '') === 'given' ? 'checked' : '' ?>>
|
||||
<?= h(t('care.given')) ?></label><label
|
||||
class="btn btn-outline-danger"><input type="radio" class="btn-check"
|
||||
class="btn btn-outline-danger care-treatment-choice"><input type="radio" class="btn-check"
|
||||
name="treatments[<?= (int)$t['id'] ?>]" value="skipped"
|
||||
<?= ($administrations[(int)$t['id']] ?? '') === 'skipped' ? 'checked' : '' ?>>
|
||||
<?= h(t('care.not_given')) ?></label></div>
|
||||
|
|
|
|||
|
|
@ -31,10 +31,10 @@
|
|||
<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.6</span>
|
||||
<h3>Compatibilité des ressources</h3>
|
||||
<p class="text-muted">Police emoji compatible avec les navigateurs et publication des médias
|
||||
renforcée pour les installations YunoHost.</p>
|
||||
<span class="badge bg-blue-lt mb-2">1.0.0-rc.7</span>
|
||||
<h3>Premier lot de tickets</h3>
|
||||
<p class="text-muted">Géocodage fiabilisé, doublons expliqués, tournées plus lisibles et animaux
|
||||
adoptables publiés dans la démonstration.</p>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
</div>
|
||||
<?php if ($saved): ?><div class="alert alert-success">✅ <?= h(t('settings.saved')) ?></div><?php endif; ?>
|
||||
<?php if ($error !== ''): ?><div class="alert alert-danger">⚠️ <?= h($error) ?></div><?php endif; ?>
|
||||
<form method="post" action="/settings/general/save" enctype="multipart/form-data">
|
||||
<form method="post" action="/settings/general/save" enctype="multipart/form-data" novalidate>
|
||||
<div class="card mb-3 overflow-hidden">
|
||||
<div class="card-status-top bg-primary"></div>
|
||||
<div class="card-header">
|
||||
|
|
@ -37,7 +37,9 @@
|
|||
</div>
|
||||
<div class="col-md-3"><label class="form-label"><?= h(t('settings.email')) ?></label><input
|
||||
class="form-control" type="email" name="association_email"
|
||||
value="<?= h($settings['association_email']) ?>"></div>
|
||||
value="<?= h($settings['association_email']) ?>"
|
||||
oninvalid="this.setCustomValidity(<?= h(json_encode(t('settings.invalid_email'))) ?>)"
|
||||
oninput="this.setCustomValidity('')"></div>
|
||||
<div class="col-12">
|
||||
<hr class="my-1">
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in a new issue