auction_view.php

main 185 lines · 9.6 KB Raw
Alex Alex Commit Initial commit 01/10/2026 09:20
1<?php
2?>
3<style>
4.auc2-detail-header { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 10px; }
5.auc2-detail-outfit { flex: 0 0 auto; }
6.auc2-detail-data { flex: 1 1 220px; font-size: 12px; line-height: 1.6; }
7.auc2-detail-data .auc2-label { color: #666; }
8.auc2-detail-bid { flex: 0 0 200px; border-left: 1px solid #ccc; padding-left: 14px; }
9.auc2-coin { width: 14px; height: 14px; vertical-align: middle; margin-left: 2px; }
10.auc2-amount { white-space: nowrap; }
11.auc2-section { margin-top: 18px; }
12.auc2-section h3 { font-size: 13px; margin: 0 0 8px; }
13.auc2-stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 24px; font-size: 12px; max-width: 520px; }
14.auc2-stats-grid > div { display: flex; justify-content: space-between; align-items: center; gap: 8px; border-bottom: 1px dotted #ccc; padding: 3px 0; }
15.auc2-skill-value { flex: 0 0 auto; white-space: nowrap; font-variant-numeric: tabular-nums; }
16.auc2-item-search { margin: 10px 0; }
17.auc2-item-grid { display: grid; grid-template-columns: repeat(auto-fill, 56px); gap: 8px; }
18.auc2-item-grid-tile { position: relative; width: 56px; height: 56px; border: 1px solid #ccc; display: flex; align-items: center; justify-content: center; }
19.auc2-item-grid-tile img { max-width: 40px; max-height: 40px; }
20.auc2-item-grid-tile .auc2-item-count { position: absolute; bottom: 2px; right: 2px; font-size: 10px; background: rgba(0,0,0,.6); color: #fff; padding: 0 3px; }
21.auc2-item-grid-tile[hidden] { display: none; }
22</style>
23
24<div class="auc2-detail-header">
25 <div class="auc2-detail-outfit">
26 <?php if ($loadOutfits): ?>
27 <img src="<?php echo $config['show_outfits']['imageServer']; ?>?id=<?php echo $character['type']; ?>&addons=<?php echo $character['addons']; ?>&head=<?php echo $character['head']; ?>&body=<?php echo $character['body']; ?>&legs=<?php echo $character['legs']; ?>&feet=<?php echo $character['feet']; ?>" alt="">
28 <?php endif; ?>
29 </div>
30 <div class="auc2-detail-data">
31 <div><?= t('common.level') ?>: <?= (int)$character['level'] ?> | <?= t('common.vocation') ?>: <?= h(vocation_id_to_name($character['vocation'])) ?> | <?= ((int)$character['sex'] === 1) ? t('common.male') : t('common.female') ?></div>
32 <?php if ((int)$character['own'] === 1): ?>
33 <div><span class="auc2-label"><?= t('common.name_label') ?></span> <a href="/characterprofile.php?name=<?php echo $character['name']; ?>"><?php echo $character['name']; ?></a></div>
34 <div><span class="auc2-label"><?= t('auc.price') ?>:</span> <span class="auc2-amount"><?= (int)$character['price'] ?><img class="auc2-coin" src="<?= theme_asset('icon-tibiacoin.png') ?>" alt=""></span></div>
35 <div><span class="auc2-label"><?= t('common.bid_label') ?></span> <?= (int)$character['bid'] ?></div>
36 <div><span class="auc2-label"><?= t('auc.deposit') ?></span> <?= (int)$character['deposit'] ?></div>
37 <?php else: ?>
38 <div><span class="auc2-label"><?= t_default('auc.start', 'Auction Start:') ?></span> <?= h(getClock($character['time_begin'], true)) ?></div>
39 <div><span class="auc2-label"><?= t_default('auc.end', 'Auction End:') ?></span> <?= h(getClock($character['time_end'], true)) ?></div>
40 <div>
41 <?php if ($bidding_period): ?>
42 <span class="auc2-label"><?= t_default('auc.remaining_short', 'Remaining:') ?></span>
43 <span data-auc2-countdown="<?= (int)$character['time_end'] ?>" data-auc2-ended-text="<?= h(t_default('auc.instant', 'Instant')) ?>"><?= h(toDuration((int)$character['time_end'] - time())) ?></span>
44 <?php else: ?>
45 <span class="auc2-label"><?= t_default('auc.type_label', 'Type:') ?></span> <?= t_default('auc.instant', 'Instant') ?>
46 <?php endif; ?>
47 </div>
48 <div><span class="auc2-label"><?= t_default('auc.min_bid', 'Minimum Bid:') ?></span> <span class="auc2-amount"><?= (int)$character['price'] ?><img class="auc2-coin" src="<?= theme_asset('icon-tibiacoin.png') ?>" alt=""></span></div>
49 <?php endif; ?>
50 </div>
51 <div class="auc2-detail-bid">
52 <?php if ((int)$character['own'] === 1): ?>
53 <?php if (!$bidding_period): ?>
54 <p><?= t('auc.bidding_ended') ?></p>
55 <form action="/auctionChar.php" method="POST">
56 <input type="hidden" name="action" value="refund">
57 <input type="hidden" name="zaid" value="<?php echo $character['zaid']; ?>">
58 <input type="submit" value="<?= t('auc.reclaim_btn') ?>">
59 </form>
60 <?php else: ?>
61 <p><?= t('auc.bid_period') ?> <?php echo toDuration($character['time_end']-time()); ?>. <?= t('auc.reclaim_after_period') ?></p>
62 <?php endif; ?>
63 <?php else: ?>
64 <?php if (is_array($account) && !empty($account)): ?>
65 <p><?= t('common.you_have') ?> <strong><?php echo $account['points']; ?></strong> <?= t('auc.points_remaining') ?></p>
66 <?php if ((int)$character['bidder_account_id'] === $this_account_id): ?>
67 <p><strong><?= t('auc.so_far_good') ?></strong>
68 <br><?= t('auc.highest_bid') ?> <?php echo (int)$character['price']-$step; ?>
69 </p>
70 <p><?= t('auc.yours_in') ?>
71 <br><?php echo toDuration((int)$character['time_end']-time()); ?>.
72 </p>
73 <?php endif; ?>
74 <form action="/auctionChar.php" method="POST">
75 <input type="hidden" name="action" value="bid">
76 <input type="hidden" name="zaid" value="<?php echo $character['zaid']; ?>">
77 <input type="number" name="price" min="<?php echo $character['price']; ?>" max="<?php echo $account['points']; ?>" step="5" value="<?php echo $character['price']; ?>" <?php if (!$bidding_period) echo 'disabled'; ?>>
78 <?php if (!$bidding_period): /* Because above input is disabled */ ?>
79 <input type="hidden" name="price" value="<?php echo $character['price']; ?>">
80 <?php endif; ?>
81 <input type="submit" value="<?php echo ($bidding_period) ? t('auc.bid_btn') : t('auc.buy_btn'); ?>">
82 </form>
83 <?php else: ?>
84 <?php if ((int)$character['bidder_account_id'] === $this_account_id): ?>
85 <p><strong><?= t('auc.so_far_good') ?></strong>
86 <br><?= t('auc.highest_bid') ?> <?php echo (int)$character['price']-$step; ?>
87 </p>
88 <p><?= t('auc.yours_in') ?>
89 <br><?php echo toDuration((int)$character['time_end']-time()); ?>.
90 </p>
91 <?php else: ?>
92 <p><?= t('auc.cannot_afford') ?></p>
93 <?php endif; ?>
94 <?php endif; ?>
95 <?php endif; ?>
96 </div>
97</div>
98
99<?php
100$auc2Skills = array(
101 array(t('char.magic_level'), (int)$character['magic']),
102 array(t('skill.fist'), (int)$character['fist']),
103 array(t('skill.club'), (int)$character['club']),
104 array(t('skill.sword'), (int)$character['sword']),
105 array(t('skill.axe'), (int)$character['axe']),
106 array(t('skill.distance'), (int)$character['dist']),
107 array(t('skill.shielding'), (int)$character['shielding']),
108 array(t('skill.fishing'), (int)$character['fishing']),
109);
110?>
111<div class="auc2-section">
112 <h3><?= t_default('auc.tab_general', 'General') ?></h3>
113 <div class="auc2-stats-grid">
114 <div><span><?= t('common.level') ?></span><span class="auc2-skill-value"><?= (int)$character['level'] ?></span></div>
115 <?php foreach ($auc2Skills as $auc2Skill): [$auc2SkillLabel, $auc2SkillValue] = $auc2Skill; ?>
116 <div>
117 <span><?= h($auc2SkillLabel) ?></span>
118 <span class="auc2-skill-value"><?= $auc2SkillValue ?></span>
119 </div>
120 <?php endforeach; ?>
121 </div>
122</div>
123
124<?php
125$auc2AllItems = array();
126foreach (($player_items ?: array()) as $item) { $auc2AllItems[] = $item; }
127foreach (($depot_items ?: array()) as $item) { $auc2AllItems[] = $item; }
128?>
129<?php if (!empty($auc2AllItems)): ?>
130 <div class="auc2-section">
131 <h3><?= t('auc.player_items') ?> &amp; <?= t('auc.depot_items') ?></h3>
132 <input type="text" class="auc2-item-search" id="auc2ItemSearch" placeholder="<?= h(t_default('auc.item_search_placeholder', 'Search item...')) ?>">
133 <div class="auc2-item-grid">
134 <?php foreach ($auc2AllItems as $item): ?>
135 <div class="auc2-item-grid-tile" data-auc2-item-name="<?= h(strtolower((string)($items[$item['itemtype']] ?? ''))) ?>" title="<?= h(($items[$item['itemtype']] ?? ('#' . $item['itemtype'])) . ' (' . (int)$item['count'] . ')') ?>">
136 <img src="<?= h(znote_item_image_url((int)$item['itemtype'])) ?>" alt="">
137 <?php if ((int)$item['count'] > 1): ?><span class="auc2-item-count"><?= (int)$item['count'] ?></span><?php endif; ?>
138 </div>
139 <?php endforeach; ?>
140 </div>
141 </div>
142<?php endif; ?>
143
144<p><a href="/auctionChar.php"><?= t('auc.go_back_list') ?></a></p>
145
146<script>
147document.addEventListener('DOMContentLoaded', function () {
148 var search = document.getElementById('auc2ItemSearch');
149 if (search) {
150 search.addEventListener('keyup', function () {
151 var needle = search.value.trim().toLowerCase();
152 document.querySelectorAll('.auc2-item-grid-tile').forEach(function (tile) {
153 var name = tile.getAttribute('data-auc2-item-name') || '';
154 tile.hidden = needle !== '' && name.indexOf(needle) === -1;
155 });
156 });
157 }
158
159 // Auction timers tick down live client-side instead of only updating on
160 // the next full page reload.
161 document.querySelectorAll('[data-auc2-countdown]').forEach(function (el) {
162 var end = parseInt(el.getAttribute('data-auc2-countdown'), 10);
163 function tick() {
164 var remaining = end - Math.floor(Date.now() / 1000);
165 if (remaining <= 0) {
166 el.textContent = el.getAttribute('data-auc2-ended-text') || '';
167 return;
168 }
169 var d = Math.floor(remaining / 86400);
170 var h = Math.floor((remaining % 86400) / 3600);
171 var m = Math.floor((remaining % 3600) / 60);
172 var s = remaining % 60;
173 var parts = [];
174 if (d > 0) parts.push(d + (d === 1 ? ' day' : ' days'));
175 if (d > 0 || h > 0) parts.push(h + (h === 1 ? ' hour' : ' hours'));
176 if (m > 0) parts.push(m + (m === 1 ? ' minute' : ' minutes'));
177 if (s > 0) parts.push(s + (s === 1 ? ' second' : ' seconds'));
178 el.textContent = parts.join(', ');
179 setTimeout(tick, 1000);
180 }
181 tick();
182 });
183});
184</script>
185
Top