added search, removed categories

This commit is contained in:
Igor Barkov [iwork] 2019-02-15 20:21:05 +02:00
parent d6444a8e96
commit 920c524f40

View File

@ -101,13 +101,9 @@ if ($get === 'sale') {
0 AS `maxdur` 0 AS `maxdur`
FROM `inventory` LEFT JOIN `magic` ON `magic` = `magic`.`id` WHERE `setsale` = 0 AND `dressed` = 0 AND `present` = "?s" AND `owner` = ?i ORDER BY `update` DESC ', '', $_SESSION['uid']); FROM `inventory` LEFT JOIN `magic` ON `magic` = `magic`.`id` WHERE `setsale` = 0 AND `dressed` = 0 AND `present` = "?s" AND `owner` = ?i ORDER BY `update` DESC ', '', $_SESSION['uid']);
$iteminfo = [];
while ($row = $data->fetch_assoc()) {
$iteminfo[] = new ShopItem($row);
}
} }
if ($get === 'unsale') { elseif ($get === 'unsale') {
$data = db::c()->query('SELECT `inventory`.*, $data = db::c()->query('SELECT `inventory`.*,
`magic`.`name` AS `magic_name`, `magic`.`name` AS `magic_name`,
`magic`.`chanse` AS `magic_chanse`, `magic`.`chanse` AS `magic_chanse`,
@ -119,13 +115,9 @@ if ($get === 'unsale') {
0 AS `maxdur` 0 AS `maxdur`
FROM `inventory` LEFT JOIN `magic` ON `magic` = `magic`.`id` WHERE `setsale` > 0 AND `dressed` = 0 AND `owner` = ?i ORDER BY `update` DESC', $_SESSION['uid']); FROM `inventory` LEFT JOIN `magic` ON `magic` = `magic`.`id` WHERE `setsale` > 0 AND `dressed` = 0 AND `owner` = ?i ORDER BY `update` DESC', $_SESSION['uid']);
$iteminfo = [];
while ($row = $data->fetch_assoc()) {
$iteminfo[] = new ShopItem($row);
}
} }
if (isset($_GET['max'])) { else if (!empty($_POST['search'])) {
$data = db::c()->query('SELECT `inventory`.*, $data = db::c()->query('SELECT `inventory`.*,
`magic`.`name` AS `magic_name`, `magic`.`name` AS `magic_name`,
`magic`.`chanse` AS `magic_chanse`, `magic`.`chanse` AS `magic_chanse`,
@ -136,11 +128,26 @@ if (isset($_GET['max'])) {
`magic`.`img` AS `magic_img`, `magic`.`img` AS `magic_img`,
0 AS `maxdur` 0 AS `maxdur`
FROM `inventory` LEFT JOIN `magic` ON `magic` = `magic`.`id` WHERE `dressed` = 0 AND `inventory`.`name` LIKE "?S%" AND `setsale` > 0 ORDER BY `setsale` ASC', $_GET['max']); FROM `inventory` LEFT JOIN `magic` ON `magic` = `magic`.`id` WHERE `dressed` = 0 AND `inventory`.`name` LIKE "%?S%" AND `setsale` > 0 ORDER BY `setsale` ASC', $_POST['search']);
$iteminfo = []; }
while ($row = $data->fetch_assoc()) {
$iteminfo[] = new ShopItem($row); else {
} $data = db::c()->query('SELECT `inventory`.*,
`magic`.`name` AS `magic_name`,
`magic`.`chanse` AS `magic_chanse`,
`magic`.`time` AS `magic_time`,
`magic`.`file` AS `magic_file`,
`magic`.`targeted` AS `magic_targeted`,
`magic`.`needcharge` AS `magic_needcharge`,
`magic`.`img` AS `magic_img`,
0 AS `maxdur`
FROM `inventory` LEFT JOIN `magic` ON `magic` = `magic`.`id` WHERE `dressed` = 0 AND `setsale` > 0 ORDER BY `setsale` ASC');
}
$iteminfo = [];
while ($row = $data->fetch_assoc()) {
$iteminfo[] = new ShopItem($row);
} }
?> ?>
@ -169,7 +176,9 @@ FROM `inventory` LEFT JOIN `magic` ON `magic` = `magic`.`id` WHERE `dressed` = 0
else { else {
echo <<<MARKET echo <<<MARKET
Список товаров.<br> Список товаров.<br>
<input name="search" disabled> <input type="submit" value="Искать товар" disabled> <form method="post">
<input name="search"> <input type="submit" value="Искать товар">
</form>
MARKET; MARKET;
} ?> } ?>
</TH> </TH>
@ -178,17 +187,7 @@ MARKET;
<TD><!--Рюкзак--> <TD><!--Рюкзак-->
<TABLE BORDER=0 WIDTH=100% CELLSPACING="1" CELLPADDING="2" BGCOLOR="#A5A5A5"> <TABLE BORDER=0 WIDTH=100% CELLSPACING="1" CELLPADDING="2" BGCOLOR="#A5A5A5">
<?php <?php
if (isset($_GET['max'])) { if ($get === 'sale') {
foreach ($iteminfo as $ii) {
echo "<tr><td style='width: 150px; text-align: center;'>";
$ii->printImage();
$ii->printControls('marketbuy');
echo "</td>";
echo "<td style='vertical-align: top;'>";
$ii->printInfo();
echo "</td></tr>";
}
} elseif ($get === 'sale') {
foreach ($iteminfo as $ii) { foreach ($iteminfo as $ii) {
echo "<tr><td style='width: 150px; text-align: center;'>"; echo "<tr><td style='width: 150px; text-align: center;'>";
$ii->printImage(); $ii->printImage();
@ -209,26 +208,14 @@ MARKET;
echo "</td></tr>"; echo "</td></tr>";
} }
} else { } else {
$data = db::c()->query('SELECT DISTINCT `img`, `name`, `nalign`, `massa` FROM `inventory` WHERE `dressed` = 0 AND `setsale` > 0 AND `present` = "?s" GROUP BY `img` ORDER BY `cost` ASC', ''); foreach ($iteminfo as $ii) {
$replacements = ['+1', '+2', '+3', '+4', '+5', ' (мф)']; echo "<tr><td style='width: 150px; text-align: center;'>";
while ($row = $data->fetch_assoc()) { $ii->printImage();
$item_name = str_replace($replacements, '', $row['name']); $ii->printControls('marketbuy');
$item = db::c()->query('SELECT COUNT(`id`), MIN(`duration`), MIN(`maxdur`), MAX(`duration`), MAX(`maxdur`), MIN(`setsale`), MAX(`setsale`) FROM `inventory` WHERE `dressed` = 0 AND `setsale` > 0 AND `present` = "?s" AND `name` LIKE "?S%"', '', $item_name)->fetch_row(); echo "</td>";
?> echo "<td style='vertical-align: top;'>";
<TR> $ii->printInfo();
<TD align=center> echo "</td></tr>";
<IMG SRC="i/sh/<?= $row['img'] ?>" ALT="">
<BR><A HREF="?max=<?= $item_name ?>">подробнее</A>
</TD>
<TD valign=top>
<?= $item_name ?>
<?php if ($row['nalign']): ?><img src="i/align_<?= $row['nalign'] ?>.gif"> <?php endif; ?>
(Масса: <?= $row['massa'] ?>) <BR> <small>(количество: <?= $item[0] ?>)</small><br>
<b>Цена: <?= round($item[5], 2) ?> - <?= round($item[6], 2) ?> кр.</b>
<BR>Долговечность: <?= $item[1] ?>-<?= $item[2] ?>/<?= $item[3] ?>-<?= $item[4] ?><BR>
</TD>
</TR>
<?
} }
} }
?> ?>