Initial import of animal_management module

This commit is contained in:
Kelin Rescue Hub
2026-04-04 13:13:00 -04:00
commit 20adb1bd1e
65 changed files with 14004 additions and 0 deletions

View File

@@ -0,0 +1,95 @@
<?php
use humhub\modules\animal_management\models\Animal;
use humhub\modules\animal_management\models\AnimalMedicalVisit;
use humhub\modules\content\components\ContentContainerActiveRecord;
use yii\helpers\Html;
/* @var Animal[] $animals */
/* @var ContentContainerActiveRecord $contentContainer */
/* @var string $queryValue */
/* @var string $heading */
/* @var array $tileFields */
/* @var array<int, array> $tileFieldOverrides */
/* @var array<int, AnimalMedicalVisit> $latestMedicalVisitByAnimal */
/* @var array<int, string> $animalImageUrls */
/* @var int $totalCount */
/* @var int $displayCount */
/* @var bool $hasMore */
/* @var int $nextCount */
/* @var bool $showAll */
$moduleEnabled = $contentContainer->moduleManager->isEnabled('animal_management');
$currentParams = Yii::$app->request->getQueryParams();
$buildProfileUrl = static function (array $overrides) use ($contentContainer, $currentParams): string {
$params = array_merge($currentParams, $overrides);
return $contentContainer->createUrl('/space_profiles/profile/view', $params);
};
?>
<h4 style="margin-top:0;"><?= Html::encode($heading) ?></h4>
<?php if ($moduleEnabled): ?>
<form method="get" action="<?= Html::encode($contentContainer->createUrl('/space_profiles/profile/view')) ?>" style="margin-bottom:12px;">
<div class="input-group">
<input
type="text"
class="form-control"
name="q"
value="<?= Html::encode($queryValue) ?>"
placeholder="<?= Html::encode(Yii::t('AnimalManagementModule.base', 'Search by name, species, or ID')) ?>"
>
<input type="hidden" name="animalFeedCount" value="10">
<input type="hidden" name="animalFeedAll" value="0">
<span class="input-group-btn">
<button class="btn btn-default" type="submit"><?= Yii::t('AnimalManagementModule.base', 'Search') ?></button>
</span>
</div>
</form>
<?php else: ?>
<div class="well well-sm" style="margin-bottom:12px;">
<?= Yii::t('AnimalManagementModule.base', 'Animal profiles are not enabled for this rescue.') ?>
</div>
<?php endif; ?>
<?php if (empty($animals)): ?>
<div class="text-muted" style="margin-bottom:10px;">
<?= Yii::t('AnimalManagementModule.base', 'No matching animal profiles found.') ?>
</div>
<?php else: ?>
<div class="row" style="margin-bottom:6px;">
<?php foreach ($animals as $animal): ?>
<?php $animalId = (int)$animal->id; ?>
<div class="col-xs-12" style="margin-bottom:12px;">
<?= $this->renderFile(Yii::getAlias('@app/modules/animal_management/views/animals/_tile.php'), [
'animal' => $animal,
'contentContainer' => $contentContainer,
'lastMedical' => $latestMedicalVisitByAnimal[$animalId] ?? null,
'imageUrl' => $animalImageUrls[$animalId] ?? '',
'tileFields' => $tileFieldOverrides[$animalId] ?? $tileFields,
'showMedicalIcon' => true,
]) ?>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php if ($moduleEnabled): ?>
<div style="display:flex;gap:8px;align-items:center;flex-wrap:wrap;">
<?php if ($hasMore): ?>
<a class="btn btn-default btn-sm" href="<?= Html::encode($buildProfileUrl(['animalFeedCount' => $nextCount, 'animalFeedAll' => 0])) ?>">
<?= Yii::t('AnimalManagementModule.base', 'Show More') ?>
</a>
<?php endif; ?>
<?php if (!$showAll && $totalCount > 0): ?>
<a class="btn btn-default btn-sm" href="<?= Html::encode($buildProfileUrl(['animalFeedAll' => 1])) ?>">
<?= Yii::t('AnimalManagementModule.base', 'Show All') ?>
</a>
<?php endif; ?>
<?php if ($totalCount > 0): ?>
<span class="text-muted" style="font-size:12px;">
<?= Yii::t('AnimalManagementModule.base', '{shown} of {total} shown', ['shown' => $displayCount, 'total' => $totalCount]) ?>
</span>
<?php endif; ?>
</div>
<?php endif; ?>