Horodate précisément les contrôles de soins
This commit is contained in:
parent
81f259ea6e
commit
a0ea338292
10 changed files with 60 additions and 12 deletions
|
|
@ -221,6 +221,20 @@ trait AnimalMedicalActions
|
|||
|
||||
$temperature = $_POST['temperature_c'] ?? null;
|
||||
$weight = $_POST['weight_kg'] ?? null;
|
||||
$notedDate = trim((string) ($_POST['noted_date'] ?? date('Y-m-d')));
|
||||
$notedTime = trim((string) ($_POST['noted_time'] ?? date('H:i')));
|
||||
$observedAt = DateTimeImmutable::createFromFormat('!Y-m-d H:i', $notedDate . ' ' . $notedTime);
|
||||
$dateErrors = DateTimeImmutable::getLastErrors();
|
||||
if (
|
||||
!$observedAt ||
|
||||
($dateErrors !== false && ($dateErrors['warning_count'] > 0 || $dateErrors['error_count'] > 0)) ||
|
||||
$observedAt->format('Y-m-d H:i') !== $notedDate . ' ' . $notedTime
|
||||
) {
|
||||
http_response_code(400);
|
||||
echo h(t('error.invalid_medical_datetime'));
|
||||
return;
|
||||
}
|
||||
$observedAtSql = $observedAt->format('Y-m-d H:i:s');
|
||||
|
||||
$clinicId = (int) ($_POST['clinic_id'] ?? 0);
|
||||
$clinicId = $clinicId > 0 ? $clinicId : null;
|
||||
|
|
@ -251,13 +265,14 @@ trait AnimalMedicalActions
|
|||
// Enregistre la note médicale avant ses éventuelles pièces jointes.
|
||||
$stmt = $db->prepare('
|
||||
INSERT INTO medical_notes
|
||||
(animal_id, kind, reason, symptoms, exam, diagnosis, plan, temperature_c, weight_kg, clinic_id, vet_name, clinic_contact_id, vet_contact_id, created_by, created_at)
|
||||
(animal_id, noted_at, kind, reason, symptoms, exam, diagnosis, plan, temperature_c, weight_kg, clinic_id, vet_name, clinic_contact_id, vet_contact_id, created_by, created_at)
|
||||
VALUES
|
||||
(:aid, :kind, :reason, :symptoms, :exam, :diagnosis, :plan, :temp, :weight, :clinic, :vet, :clinic_contact, :vet_contact, :created_by, :created)
|
||||
(:aid, :noted_at, :kind, :reason, :symptoms, :exam, :diagnosis, :plan, :temp, :weight, :clinic, :vet, :clinic_contact, :vet_contact, :created_by, :created)
|
||||
');
|
||||
|
||||
$stmt->execute([
|
||||
':aid' => $animalId,
|
||||
':noted_at' => $observedAtSql,
|
||||
':kind' => $kind,
|
||||
':reason' => $reason,
|
||||
':symptoms' => $symptoms,
|
||||
|
|
@ -282,7 +297,7 @@ trait AnimalMedicalActions
|
|||
$animalId,
|
||||
(int) $_POST['tariff_id'],
|
||||
1,
|
||||
substr(self::now(), 0, 10),
|
||||
$observedAt->format('Y-m-d'),
|
||||
'Ajoutée avec la note médicale',
|
||||
);
|
||||
}
|
||||
|
|
@ -344,7 +359,7 @@ trait AnimalMedicalActions
|
|||
",
|
||||
)->execute([
|
||||
':aid' => $animalId,
|
||||
':at' => self::now(),
|
||||
':at' => $observedAtSql,
|
||||
':v' => (float) $weight,
|
||||
':created_by' => Auth::id(),
|
||||
]);
|
||||
|
|
@ -358,7 +373,7 @@ trait AnimalMedicalActions
|
|||
$db->prepare(
|
||||
"UPDATE animals SET sterilized=1,sterilization_status='yes',sterilization_date=COALESCE(sterilization_date,date(:date)),sterilization_vet_contact_id=COALESCE(:vet,sterilization_vet_contact_id),sterilization_clinic_contact_id=COALESCE(:clinic,sterilization_clinic_contact_id) WHERE id=:id",
|
||||
)->execute([
|
||||
':date' => self::now(),
|
||||
':date' => $observedAtSql,
|
||||
':vet' => $vetContact['id'] ?? null,
|
||||
':clinic' => $clinicContact['id'] ?? null,
|
||||
':id' => $animalId,
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
/** @var array $vaccines */
|
||||
$defaultDue = date('Y-m-d', strtotime('+1 year'));
|
||||
$today = date('Y-m-d');
|
||||
$currentTime = date('H:i');
|
||||
?>
|
||||
|
||||
<?php if ($canViewMedical): ?>
|
||||
|
|
@ -612,6 +613,16 @@ $today = date('Y-m-d');
|
|||
<input type="hidden" name="animal_id" value="<?= (int)$animal['id'] ?>">
|
||||
|
||||
<div class="row g-2">
|
||||
<div class="col-md-4">
|
||||
<label class="form-label"><?= h(t('common.date')) ?></label>
|
||||
<input class="form-control" type="date" name="noted_date" value="<?= h($today) ?>" required>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<label class="form-label"><?= h(t('agenda.time')) ?></label>
|
||||
<input class="form-control" type="time" name="noted_time" value="<?= h($currentTime) ?>" required>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<label class="form-label"><?= h(t('animal.form.type')) ?></label>
|
||||
<select class="form-select" name="kind">
|
||||
|
|
@ -625,7 +636,7 @@ $today = date('Y-m-d');
|
|||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-md-8">
|
||||
<div class="col-12">
|
||||
<label class="form-label"><?= h(t('animal.reason')) ?></label>
|
||||
<input class="form-control" name="reason" id="medicalReason"
|
||||
placeholder="<?= h(t('animal.reason_placeholder')) ?>">
|
||||
|
|
|
|||
|
|
@ -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.18</span>
|
||||
<h3>Site public</h3>
|
||||
<p class="text-muted">Informations légales accessibles sur chaque page, insertion guidée des images
|
||||
dans les contenus et liens sociaux plus lisibles.</p>
|
||||
<span class="badge bg-blue-lt mb-2">1.0.0-rc.19</span>
|
||||
<h3>Suivi des soins</h3>
|
||||
<p class="text-muted">Date et heure modifiables pour distinguer précisément plusieurs contrôles et
|
||||
mesures réalisés au cours d’une même journée.</p>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in a new issue