151 lines
7.1 KiB
PHP
151 lines
7.1 KiB
PHP
<?php
|
|
|
|
use humhub\modules\animal_management\models\AnimalTransfer;
|
|
use humhub\modules\space\models\Space;
|
|
use yii\helpers\Html;
|
|
|
|
/* @var AnimalTransfer $transfer */
|
|
/* @var Space $space */
|
|
/* @var string $otherRescueName */
|
|
/* @var string $otherRescueUrl */
|
|
/* @var string $animalProfileUrl */
|
|
/* @var string $imageUrl */
|
|
/* @var bool $isIncoming */
|
|
|
|
$animalName = $transfer->animal ? $transfer->animal->getDisplayName() : ('#' . (int)$transfer->animal_id);
|
|
$statusLabel = AnimalTransfer::statusOptions()[$transfer->status] ?? (string)$transfer->status;
|
|
$hasImage = $imageUrl !== '' && (preg_match('/^https?:\/\//i', $imageUrl) || substr($imageUrl, 0, 1) === '/');
|
|
$statusTextColor = '#ffffff';
|
|
switch ($transfer->status) {
|
|
case AnimalTransfer::STATUS_REQUESTED:
|
|
$statusTextColor = '#facc15';
|
|
break;
|
|
case AnimalTransfer::STATUS_ACCEPTED:
|
|
$statusTextColor = '#4ade80';
|
|
break;
|
|
case AnimalTransfer::STATUS_COMPLETED:
|
|
$statusTextColor = '#60a5fa';
|
|
break;
|
|
case AnimalTransfer::STATUS_DECLINED:
|
|
$statusTextColor = '#fca5a5';
|
|
break;
|
|
case AnimalTransfer::STATUS_CANCELLED:
|
|
$statusTextColor = '#d1d5db';
|
|
break;
|
|
}
|
|
|
|
static $transferActionButtonStylePrinted = false;
|
|
if (!$transferActionButtonStylePrinted):
|
|
$transferActionButtonStylePrinted = true;
|
|
?>
|
|
<style>
|
|
.animal-transfer-action-btn {
|
|
border-radius: 999px;
|
|
border: 1px solid rgba(15, 23, 42, 0.24);
|
|
background: rgba(255, 255, 255, 0.92);
|
|
color: #0f172a !important;
|
|
font-weight: 700;
|
|
box-shadow: 0 2px 10px rgba(15, 23, 42, 0.2);
|
|
}
|
|
|
|
@media (prefers-color-scheme: dark) {
|
|
.animal-transfer-action-btn {
|
|
border-color: rgba(226, 232, 240, 0.34);
|
|
background: rgba(15, 23, 42, 0.72);
|
|
color: #f8fafc !important;
|
|
}
|
|
}
|
|
</style>
|
|
<?php endif; ?>
|
|
?>
|
|
|
|
<div class="panel panel-default" style="margin-bottom:0;overflow:hidden;border-radius:12px;border:0;box-shadow:0 8px 24px rgba(15,23,42,0.14);">
|
|
<div style="position:relative;min-height:190px;background:#d8dee8;">
|
|
<?php if ($hasImage): ?>
|
|
<img src="<?= Html::encode($imageUrl) ?>" alt="<?= Html::encode($animalName) ?>" style="position:absolute;inset:0;width:100%;height:100%;object-fit:cover;">
|
|
<?php else: ?>
|
|
<div style="position:absolute;inset:0;display:flex;align-items:center;justify-content:center;color:#8d98a5;">
|
|
<i class="fa fa-paw fa-3x"></i>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<div style="position:absolute;inset:0;background:linear-gradient(180deg, rgba(7,10,16,0.08) 0%, rgba(7,10,16,0.6) 58%, rgba(7,10,16,0.82) 100%);"></div>
|
|
|
|
<div style="position:absolute;top:12px;left:12px;z-index:2;max-width:60%;">
|
|
<?php if (!empty($otherRescueUrl)): ?>
|
|
<?= Html::a(
|
|
Html::encode($otherRescueName),
|
|
$otherRescueUrl,
|
|
[
|
|
'style' => 'display:inline-block;background:rgba(15,23,42,0.66);border:1px solid rgba(255,255,255,0.28);color:#fff;padding:4px 10px;border-radius:999px;font-size:12px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%;text-decoration:none;'
|
|
]
|
|
) ?>
|
|
<?php else: ?>
|
|
<span style="display:inline-block;background:rgba(15,23,42,0.66);border:1px solid rgba(255,255,255,0.28);color:#fff;padding:4px 10px;border-radius:999px;font-size:12px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%;">
|
|
<?= Html::encode($otherRescueName) ?>
|
|
</span>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<div style="position:absolute;top:12px;right:12px;z-index:2;display:flex;gap:6px;flex-wrap:wrap;justify-content:flex-end;max-width:65%;">
|
|
<?php if ($isIncoming && $transfer->status === AnimalTransfer::STATUS_REQUESTED): ?>
|
|
<?= Html::a(
|
|
Yii::t('AnimalManagementModule.base', 'Accept'),
|
|
$space->createUrl('/animal_management/animals/transfer-respond', ['id' => $transfer->id, 'decision' => 'accept']),
|
|
[
|
|
'class' => 'btn btn-xs btn-default animal-transfer-action-btn',
|
|
'data-method' => 'post',
|
|
]
|
|
) ?>
|
|
<?= Html::a(
|
|
Yii::t('AnimalManagementModule.base', 'Decline'),
|
|
$space->createUrl('/animal_management/animals/transfer-respond', ['id' => $transfer->id, 'decision' => 'decline']),
|
|
[
|
|
'class' => 'btn btn-xs btn-default animal-transfer-action-btn',
|
|
'data-method' => 'post',
|
|
]
|
|
) ?>
|
|
<?php elseif ($isIncoming && $transfer->status === AnimalTransfer::STATUS_ACCEPTED): ?>
|
|
<?= Html::a(
|
|
Yii::t('AnimalManagementModule.base', 'Complete Transfer'),
|
|
$space->createUrl('/animal_management/animals/transfer-complete', ['id' => $transfer->id]),
|
|
[
|
|
'class' => 'btn btn-xs btn-default animal-transfer-action-btn',
|
|
'data-method' => 'post',
|
|
]
|
|
) ?>
|
|
<?php elseif (!$isIncoming && in_array($transfer->status, [AnimalTransfer::STATUS_REQUESTED, AnimalTransfer::STATUS_ACCEPTED], true)): ?>
|
|
<?= Html::a(
|
|
Yii::t('AnimalManagementModule.base', 'Cancel Request'),
|
|
$space->createUrl('/animal_management/animals/transfer-cancel', ['id' => $transfer->id]),
|
|
[
|
|
'class' => 'btn btn-xs btn-default animal-transfer-action-btn',
|
|
'data-method' => 'post',
|
|
]
|
|
) ?>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<div style="position:absolute;left:12px;right:12px;bottom:12px;z-index:2;color:#fff;">
|
|
<div style="display:flex;align-items:flex-end;justify-content:space-between;gap:10px;">
|
|
<div style="font-size:24px;font-weight:700;line-height:1.15;text-shadow:0 2px 8px rgba(0,0,0,0.45);">
|
|
<?php if (!empty($animalProfileUrl)): ?>
|
|
<?= Html::a(
|
|
Html::encode($animalName),
|
|
$animalProfileUrl,
|
|
[
|
|
'style' => 'color:#fff;text-decoration:none;'
|
|
]
|
|
) ?>
|
|
<?php else: ?>
|
|
<?= Html::encode($animalName) ?>
|
|
<?php endif; ?>
|
|
</div>
|
|
<span style="display:inline-block;background:rgba(15,23,42,0.7);border:1px solid rgba(255,255,255,0.22);padding:5px 12px;border-radius:999px;font-size:14px;font-weight:800;letter-spacing:0.02em;color:<?= Html::encode($statusTextColor) ?>;text-transform:uppercase;white-space:nowrap;">
|
|
<?= Html::encode($statusLabel) ?>
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|