another selling items final

This commit is contained in:
lopar 2019-01-14 22:37:35 +02:00
parent 99eb435c9e
commit 98744bde3f

146
shop.php
View File

@ -14,6 +14,65 @@ if ($user['battle'] != 0) {
}
$saleItems = false;
$shopCategoryType = empty($_POST['sale']) ?: $_POST['sale'];
$shopCategoryTypeNumber = empty($_GET['otdel']) ?: $_GET['otdel'];
switch ($shopCategoryTypeNumber) {
default:
$shopCategoryType = "Предметы в инвентаре";
$saleItems = true;
break;
case 1:
$shopCategoryType = "Кастеты и ножи";
break;
case 11:
$shopCategoryType = "Топоры";
break;
case 12:
$shopCategoryType = "Дубины и булавы";
break;
case 13:
$shopCategoryType = "Мечи";
break;
case 2:
$shopCategoryType = "Сапоги";
break;
case 21:
$shopCategoryType = "Перчатки";
break;
case 22:
$shopCategoryType = "Легкая броня";
break;
case 23:
$shopCategoryType = "Тяжелая броня";
break;
case 24:
$shopCategoryType = "Шлемы";
break;
case 3:
$shopCategoryType = "Щиты";
break;
case 4:
$shopCategoryType = "Серьги";
break;
case 41:
$shopCategoryType = "Ожерелья";
break;
case 42:
$shopCategoryType = "Кольца";
break;
case 5:
$shopCategoryType = "Заклинания: нейтральные";
break;
case 51:
$shopCategoryType = "Заклинания: боевые и защитные";
break;
case 6:
$shopCategoryType = "Амуниция";
break;
case 52:
$shopCategoryType = "Руны";
break;
}
if (false == $saleItems) {
$shopItems = db::c()->query('SELECT `shop`.*,
@ -73,7 +132,6 @@ if ($sellItemId) {
}
if (!empty($_GET['buy'])) {
$dress = db::c()->query('SELECT * FROM `shop` WHERE `id`=?i', $_GET['buy'])->fetch_assoc();
$itemWeight = db::c()->query('SELECT sum(`massa`) AS `m` FROM `inventory` WHERE `owner` = ?i AND `setsale` = 0', $_SESSION['uid'])->fetch_assoc();
@ -144,66 +202,6 @@ if (!empty($_GET['buy'])) {
$status = "Недостаточно денег или нет вещей в наличии.";
}
}
$shopCategoryType = empty($_POST['sale']) ?: $_POST['sale'];
$shopCategoryTypeNumber = empty($_GET['otdel']) ?: $_GET['otdel'];
switch ($shopCategoryTypeNumber) {
default:
$shopCategoryType = "Предметы в инвентаре";
$saleItems = true;
break;
case 1:
$shopCategoryType = "Кастеты и ножи";
break;
case 11:
$shopCategoryType = "Топоры";
break;
case 12:
$shopCategoryType = "Дубины и булавы";
break;
case 13:
$shopCategoryType = "Мечи";
break;
case 2:
$shopCategoryType = "Сапоги";
break;
case 21:
$shopCategoryType = "Перчатки";
break;
case 22:
$shopCategoryType = "Легкая броня";
break;
case 23:
$shopCategoryType = "Тяжелая броня";
break;
case 24:
$shopCategoryType = "Шлемы";
break;
case 3:
$shopCategoryType = "Щиты";
break;
case 4:
$shopCategoryType = "Серьги";
break;
case 41:
$shopCategoryType = "Ожерелья";
break;
case 42:
$shopCategoryType = "Кольца";
break;
case 5:
$shopCategoryType = "Заклинания: нейтральные";
break;
case 51:
$shopCategoryType = "Заклинания: боевые и защитные";
break;
case 6:
$shopCategoryType = "Амуниция";
break;
case 52:
$shopCategoryType = "Руны";
break;
}
?>
<!DOCTYPE html>
<html>
@ -261,33 +259,7 @@ switch ($shopCategoryTypeNumber) {
echo "</td></tr>";
}
// Выбираем всё потому что эту выборку потом использует showitem();
$data = db::c()->query('SELECT * FROM `inventory` WHERE `owner` = ?i AND `dressed` = 0 AND `setsale` = 0 AND `cost` > 0 AND `present` = "?n" AND `tradesale` = 0 AND `podzem` = 0 AND `goden` = 0 ORDER BY `update` DESC', $user['id'], null);
while ($row = $data->fetch_assoc()) {
$price = $row['cost'] * 0.1;
if ($row['koll']) {
$price *= $row['koll'];
}
if ($row['type'] == 12) {
$allcost = round($price * (1 - $row['duration'] / $row['maxdur']), 2);
} else {
$allcost = round($price - $row['duration'] * ($row['cost'] / ($row['maxdur'] * 10)), 2);
}
?>
<tr>
<td align=center style='width: 150px;'>
<img src="i/sh/<?= $row['img'] ?>" border=0>
<br><a href="shop.php?sell=<?= $row['id'] ?>&sid=&sale=1">продать
за <?= $allcost ?></a>
</td>
<td valign=top class="row">
<?php showitem($row); ?>
</td>
</tr>
<?php
}
} else {
foreach ($iteminfo as $ii) {
echo "<tr><td style='width: 150px; text-align: center;'>";