185 lines
12 KiB
PHP
185 lines
12 KiB
PHP
<?php
|
|
|
|
use humhub\libs\Html;
|
|
|
|
/*
|
|
* @var array $donationHistoryRows
|
|
* @var bool $showDonationSettingsButton
|
|
* @var string $goalEditorToggleId
|
|
* @var int $existingGoalId
|
|
* @var string $createInlineGoalUrl
|
|
* @var string $existingGoalTitle
|
|
* @var float $existingGoalTargetAmount
|
|
* @var string $existingGoalDescription
|
|
* @var string $existingGoalImage
|
|
* @var array $galleryUrls
|
|
* @var \humhub\modules\animal_management\models\Animal $animal
|
|
* @var int $existingGoalActive
|
|
* @var string $fileFieldId
|
|
* @var string $previewId
|
|
* @var string $quickDonateToggleId
|
|
* @var string $quickDonatePanelId
|
|
*/
|
|
?>
|
|
<div class="animal-tile-quick-donate-layout<?= $showDonationSettingsButton ? ' has-goal-settings' : '' ?>">
|
|
<div class="animal-tile-quick-donate-history-col">
|
|
<div style="font-size:14px;font-weight:700;color:#f8fafc;margin-bottom:6px;"><?= Yii::t('DonationsModule.base', 'Donation History') ?></div>
|
|
<?php if (empty($donationHistoryRows)): ?>
|
|
<div style="font-size:12px;color:rgba(226,232,240,0.9);"><?= Yii::t('DonationsModule.base', 'No donations yet.') ?></div>
|
|
<?php else: ?>
|
|
<div class="animal-tile-scroll-region" style="flex:1 1 auto;min-height:0;overflow-y:auto;">
|
|
<?php foreach ($donationHistoryRows as $donationRow): ?>
|
|
<div class="animal-tile-donation-history-item">
|
|
<div class="animal-tile-donation-history-meta">
|
|
<?php if (!empty($donationRow['avatarUrl'])): ?>
|
|
<img class="animal-tile-donation-history-avatar" src="<?= Html::encode((string)$donationRow['avatarUrl']) ?>" alt="<?= Html::encode((string)$donationRow['donor']) ?>">
|
|
<?php else: ?>
|
|
<span class="animal-tile-donation-history-avatar animal-tile-donation-history-avatar-fallback">
|
|
<i class="fa fa-user"></i>
|
|
</span>
|
|
<?php endif; ?>
|
|
<div class="animal-tile-donation-history-identity">
|
|
<?php if (!empty($donationRow['donorUrl'])): ?>
|
|
<?= Html::a(
|
|
Html::encode($donationRow['donor']),
|
|
(string)$donationRow['donorUrl'],
|
|
['class' => 'animal-tile-donation-history-name']
|
|
) ?>
|
|
<?php else: ?>
|
|
<span class="animal-tile-donation-history-name"><?= Html::encode($donationRow['donor']) ?></span>
|
|
<?php endif; ?>
|
|
<span class="animal-tile-donation-history-when"><?= Html::encode((string)($donationRow['when'] ?? '')) ?></span>
|
|
</div>
|
|
</div>
|
|
<span class="animal-tile-donation-history-amount"><?= Html::encode($donationRow['amount']) ?></span>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
__ANIMAL_TILE_QUICK_DONATE_FORM_SLOT__
|
|
|
|
<?php if ($showDonationSettingsButton): ?>
|
|
<div class="animal-tile-quick-donate-goal-col">
|
|
<input type="checkbox" id="<?= Html::encode($goalEditorToggleId) ?>" class="animal-tile-goal-editor-toggle" <?= $existingGoalId > 0 ? 'checked' : '' ?>>
|
|
<?php if ($existingGoalId <= 0): ?>
|
|
<label for="<?= Html::encode($goalEditorToggleId) ?>" class="btn btn-default btn-xs animal-tile-set-goal-btn" style="margin:0 0 8px 0;align-self:flex-start;">
|
|
<i class="fa fa-plus"></i> <?= Yii::t('DonationsModule.base', 'Set Goal') ?>
|
|
</label>
|
|
<?php endif; ?>
|
|
|
|
<div class="animal-tile-goal-editor-fields animal-tile-scroll-region" style="<?= $existingGoalId > 0 ? 'display:flex;flex-direction:column;flex:1 1 auto;min-height:0;overflow-y:auto;' : 'display:none;flex-direction:column;flex:1 1 auto;min-height:0;overflow-y:auto;' ?>">
|
|
<?= Html::beginForm($createInlineGoalUrl, 'post', [
|
|
'enctype' => 'multipart/form-data',
|
|
'style' => 'margin:0;',
|
|
]) ?>
|
|
<?= Html::hiddenInput(Yii::$app->request->csrfParam, Yii::$app->request->getCsrfToken()) ?>
|
|
<?= Html::hiddenInput('DonationGoalForm[id]', $existingGoalId) ?>
|
|
<?= Html::hiddenInput('DonationGoalForm[goal_type]', 'animal') ?>
|
|
<?= Html::hiddenInput('DonationGoalForm[target_animal_id]', (int)$animal->id) ?>
|
|
<?= Html::hiddenInput('DonationGoalForm[is_active]', $existingGoalActive) ?>
|
|
|
|
<div style="display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:8px;">
|
|
<div style="font-size:14px;font-weight:700;color:#f8fafc;"><?= Yii::t('DonationsModule.base', 'Goal Settings') ?></div>
|
|
<div style="display:flex;align-items:center;gap:8px;">
|
|
<button type="submit" class="animal-tile-goal-header-action" title="<?= Yii::t('DonationsModule.base', 'Save Goal') ?>" aria-label="<?= Yii::t('DonationsModule.base', 'Save Goal') ?>">
|
|
<i class="fa fa-check"></i>
|
|
</button>
|
|
<label for="<?= Html::encode($quickDonateToggleId) ?>" class="animal-tile-goal-header-action" title="<?= Yii::t('AnimalManagementModule.base', 'Close') ?>" aria-label="<?= Yii::t('AnimalManagementModule.base', 'Close') ?>">
|
|
<i class="fa fa-times"></i>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="animal-tile-goal-title-target-row" style="display:grid;grid-template-columns:minmax(0,1fr) minmax(0,180px);gap:10px;align-items:end;margin-bottom:8px;">
|
|
<div class="form-group" style="margin-bottom:0;min-width:0;">
|
|
<label style="font-size:12px;font-weight:600;margin-bottom:4px;display:block;"><?= Yii::t('DonationsModule.base', 'Title') ?></label>
|
|
<?= Html::textInput('DonationGoalForm[title]', $existingGoalTitle, [
|
|
'class' => 'form-control input-sm',
|
|
'maxlength' => 190,
|
|
'required' => true,
|
|
]) ?>
|
|
</div>
|
|
|
|
<div class="form-group" style="margin-bottom:0;min-width:0;">
|
|
<label style="font-size:12px;font-weight:600;margin-bottom:4px;display:block;"><?= Yii::t('DonationsModule.base', 'Target') ?></label>
|
|
<div class="input-group" style="width:100%;max-width:none;">
|
|
<span class="input-group-addon" style="background:rgba(255,255,255,0.12);border-color:rgba(255,255,255,0.24);color:#f8fafc;">$</span>
|
|
<?= Html::input('number', 'DonationGoalForm[target_amount]', $existingGoalTargetAmount > 0 ? (string)round($existingGoalTargetAmount) : '', [
|
|
'class' => 'form-control input-sm',
|
|
'step' => '1',
|
|
'min' => '1',
|
|
'inputmode' => 'numeric',
|
|
'required' => true,
|
|
]) ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group" style="margin-bottom:8px;">
|
|
<label style="font-size:12px;font-weight:600;margin-bottom:4px;display:block;"><?= Yii::t('DonationsModule.base', 'Description') ?></label>
|
|
<?= Html::textarea('DonationGoalForm[description]', $existingGoalDescription, [
|
|
'class' => 'form-control input-sm',
|
|
'rows' => 2,
|
|
]) ?>
|
|
</div>
|
|
|
|
<div class="form-group" style="margin-bottom:8px;">
|
|
<label style="font-size:12px;font-weight:600;margin-bottom:4px;display:block;"><?= Yii::t('DonationsModule.base', 'Image') ?></label>
|
|
<div class="animal-tile-goal-image-row" style="display:flex;align-items:flex-start;gap:10px;margin-bottom:8px;">
|
|
<div id="<?= Html::encode($previewId) ?>" class="animal-tile-goal-selected-image text-muted" style="font-size:12px;">
|
|
<?php if ($existingGoalImage !== ''): ?>
|
|
<img class="animal-tile-goal-selected-image-thumb" src="<?= Html::encode($existingGoalImage) ?>" alt="">
|
|
<?php else: ?>
|
|
<span class="animal-tile-goal-selected-image-empty"><?= Yii::t('DonationsModule.base', 'No image selected.') ?></span>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<div class="animal-tile-goal-image-list" style="display:flex;flex-wrap:wrap;gap:6px;min-width:0;flex:1 1 auto;align-content:flex-start;">
|
|
<?php if (!empty($galleryUrls)): ?>
|
|
<?php foreach ($galleryUrls as $galleryIndex => $galleryUrl): ?>
|
|
<?php $galleryOptionId = 'animal-donation-gallery-option-' . (int)$animal->id . '-' . (int)$galleryIndex; ?>
|
|
<div style="position:relative;">
|
|
<input
|
|
type="radio"
|
|
class="animal-donation-gallery-radio"
|
|
id="<?= Html::encode($galleryOptionId) ?>"
|
|
name="DonationGoalForm[imageGalleryPath]"
|
|
value="<?= Html::encode($galleryUrl) ?>"
|
|
data-preview="#<?= Html::encode($previewId) ?>"
|
|
data-editor-bg="#<?= Html::encode($quickDonatePanelId) ?>"
|
|
<?= $existingGoalImage === $galleryUrl ? 'checked' : '' ?>
|
|
>
|
|
<label
|
|
for="<?= Html::encode($galleryOptionId) ?>"
|
|
class="animal-donation-inline-gallery-item"
|
|
style="display:block;border:1px solid rgba(255,255,255,0.2);background:rgba(15,23,42,0.22);padding:3px;border-radius:4px;line-height:0;pointer-events:auto;cursor:pointer;"
|
|
>
|
|
<img src="<?= Html::encode($galleryUrl) ?>" alt="" style="width:56px;height:56px;object-fit:cover;border-radius:2px;">
|
|
</label>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
<?php else: ?>
|
|
<div class="text-muted" style="font-size:12px;align-self:center;"><?= Yii::t('DonationsModule.base', 'No gallery images found for this animal.') ?></div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<?= Html::fileInput('DonationGoalForm[imageFile]', null, [
|
|
'id' => $fileFieldId,
|
|
'class' => 'js-animal-donation-upload animal-tile-goal-upload-input',
|
|
'data-preview' => '#' . $previewId,
|
|
'data-editor-bg' => '#' . $quickDonatePanelId,
|
|
'accept' => 'image/*',
|
|
]) ?>
|
|
<label for="<?= Html::encode($fileFieldId) ?>" class="animal-tile-goal-upload-btn">
|
|
<?= Yii::t('DonationsModule.base', 'Upload') ?>
|
|
</label>
|
|
</div>
|
|
<?= Html::endForm() ?>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|