88 lines
4.0 KiB
PHP
88 lines
4.0 KiB
PHP
<?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 $heading */
|
|
/* @var array $tileFields */
|
|
/* @var array<int, array> $tileFieldOverrides */
|
|
/* @var array<int, AnimalMedicalVisit> $latestMedicalVisitByAnimal */
|
|
/* @var array<int, string> $animalImageUrls */
|
|
/* @var array<int, mixed> $animalDonationGoalsByAnimal */
|
|
/* @var bool $showDonationSettingsButton */
|
|
/* @var int $totalCount */
|
|
/* @var int $page */
|
|
/* @var int $pageCount */
|
|
/* @var bool $hasPreviousPage */
|
|
/* @var bool $hasNextPage */
|
|
|
|
$moduleEnabled = $contentContainer->moduleManager->isEnabled('animal_management');
|
|
$allAnimalsUrl = $contentContainer->createUrl('/animal_management/animals/index');
|
|
$currentParams = Yii::$app->request->getQueryParams();
|
|
$buildProfileUrl = static function (array $overrides) use ($contentContainer, $currentParams): string {
|
|
unset($currentParams['q'], $currentParams['animalFeedCount'], $currentParams['animalFeedAll']);
|
|
$params = array_merge($currentParams, $overrides);
|
|
return $contentContainer->createUrl('/space_profiles/profile/view', $params);
|
|
};
|
|
?>
|
|
|
|
<?php if (!$moduleEnabled): ?>
|
|
<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,
|
|
'showDonationSettingsButton' => $showDonationSettingsButton,
|
|
'existingDonationGoal' => $animalDonationGoalsByAnimal[$animalId] ?? null,
|
|
'tileLayoutMode' => 'rows',
|
|
]) ?>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php if ($moduleEnabled && $totalCount > 0): ?>
|
|
<div style="display:flex;align-items:center;justify-content:space-between;gap:8px;flex-wrap:wrap;">
|
|
<div class="text-muted" style="font-size:12px;">
|
|
<?= Yii::t('AnimalManagementModule.base', 'Page {page} of {pages}', ['page' => $page, 'pages' => $pageCount]) ?>
|
|
</div>
|
|
<div style="display:flex;align-items:center;gap:8px;">
|
|
<?php if ($hasPreviousPage): ?>
|
|
<a class="btn btn-default btn-sm" href="<?= Html::encode($buildProfileUrl(['animalFeedPage' => $page - 1])) ?>">
|
|
<?= Yii::t('AnimalManagementModule.base', 'Previous') ?>
|
|
</a>
|
|
<?php endif; ?>
|
|
<?php if ($hasNextPage): ?>
|
|
<a class="btn btn-default btn-sm" href="<?= Html::encode($buildProfileUrl(['animalFeedPage' => $page + 1])) ?>">
|
|
<?= Yii::t('AnimalManagementModule.base', 'Next') ?>
|
|
</a>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
<div style="margin-top:10px;text-align:center;">
|
|
<a href="<?= Html::encode($allAnimalsUrl) ?>" style="font-weight:700;text-decoration:underline;">
|
|
<?= Yii::t('AnimalManagementModule.base', 'All Animals') ?>
|
|
</a>
|
|
</div>
|
|
<?php endif; ?>
|