tests
This commit is contained in:
parent
f61dd3f527
commit
313870a1fc
@ -34,33 +34,44 @@ class ShopItem extends Item
|
|||||||
*/
|
*/
|
||||||
public function printControls($shopType = false)
|
public function printControls($shopType = false)
|
||||||
{
|
{
|
||||||
switch ($shopType) {
|
if ($shopType === 'marketput') {
|
||||||
default:
|
echo <<<BTN
|
||||||
$btnValue = "Купить за " . intval($this->cost) . " кр.";
|
<form method="post">
|
||||||
$btnLink = "/shop.php?buy={$this->id}&rnd=" . mt_rand();
|
<input placeholder="Цена" name="cost">
|
||||||
break;
|
<input type="hidden" name="putId" value="{$this->id}">
|
||||||
case 'ashop':
|
<br><input type="submit" name="putToMarket" value="Cдать в магазин">
|
||||||
$btnValue = "Купить за " . intval($this->ecost) . " eкр.";
|
</form>
|
||||||
$btnLink = "/ashop.php?buy={$this->id}&rnd=" . mt_rand();
|
BTN;
|
||||||
break;
|
|
||||||
case 'sell':
|
|
||||||
$btnValue = "Продать";
|
|
||||||
$btnLink = "/shop.php?sell={$this->id}&rnd=" . mt_rand();
|
|
||||||
break;
|
|
||||||
case 'marketgetback':
|
|
||||||
$btnValue = "Снять с продажи";
|
|
||||||
$btnLink = "?back={$this->id}&rnd=" . mt_rand();
|
|
||||||
break;
|
|
||||||
case 'marketshowmore':
|
|
||||||
$btnValue = "Развернуть";
|
|
||||||
$btnLink = "?otdel={$this->otdel}&set={$this->id}&rnd=" . mt_rand();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
echo <<<BTN
|
} else {
|
||||||
|
switch ($shopType) {
|
||||||
|
default:
|
||||||
|
$btnValue = "Купить за " . intval($this->cost) . " кр.";
|
||||||
|
$btnLink = "/shop.php?buy={$this->id}&rnd=" . mt_rand();
|
||||||
|
break;
|
||||||
|
case 'ashop':
|
||||||
|
$btnValue = "Купить за " . intval($this->ecost) . " eкр.";
|
||||||
|
$btnLink = "/ashop.php?buy={$this->id}&rnd=" . mt_rand();
|
||||||
|
break;
|
||||||
|
case 'sell':
|
||||||
|
$btnValue = "Продать";
|
||||||
|
$btnLink = "/shop.php?sell={$this->id}&rnd=" . mt_rand();
|
||||||
|
break;
|
||||||
|
case 'marketgetback':
|
||||||
|
$btnValue = "Снять с продажи";
|
||||||
|
$btnLink = "?back={$this->id}&rnd=" . mt_rand();
|
||||||
|
break;
|
||||||
|
case 'marketshowmore':
|
||||||
|
$btnValue = "Развернуть";
|
||||||
|
$btnLink = "?otdel={$this->otdel}&set={$this->id}&rnd=" . mt_rand();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo <<<BTN
|
||||||
<p><input type="button" style="background: darkgrey; border: 1px solid grey; border-radius: 2px;" value="{$btnValue}"
|
<p><input type="button" style="background: darkgrey; border: 1px solid grey; border-radius: 2px;" value="{$btnValue}"
|
||||||
onclick="location='{$btnLink}'">
|
onclick="location='{$btnLink}'">
|
||||||
BTN;
|
BTN;
|
||||||
if ($this->count > 0) echo "<br><small>В наличии: {$this->count} штук</small>";
|
if ($this->count > 0) echo "<br><small>В наличии: {$this->count} штук</small>";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -50,7 +50,11 @@ if ($returningItemId) {
|
|||||||
} else $status = "Предмет не найден на полках магазина!";
|
} else $status = "Предмет не найден на полках магазина!";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_POST['puttomarket']) AND $puttingItemPrice) echo "<h1>WHOA!</h1>";
|
if (isset($_POST['putToMarket'])) {
|
||||||
|
if ($puttingItemPrice > 0) {
|
||||||
|
$dress = db::c()->query()->fetch_assoc();
|
||||||
|
} else $status = "Хорошая попытка…";
|
||||||
|
}
|
||||||
|
|
||||||
if ($_GET['set']) {
|
if ($_GET['set']) {
|
||||||
|
|
||||||
@ -199,14 +203,6 @@ switch ($shopCategoryTypeNumber) {
|
|||||||
<link rel=stylesheet href="css/main.css">
|
<link rel=stylesheet href="css/main.css">
|
||||||
<script src="js/main.js"></script>
|
<script src="js/main.js"></script>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<SCRIPT LANGUAGE="JavaScript">
|
|
||||||
function sale(name, txt, n, kr) {
|
|
||||||
var s = prompt("Сдать в магазин \"" + txt + "\". Укажите цену:", kr);
|
|
||||||
if ((s != null) && (s !== '')) {
|
|
||||||
location.href = "?sale=" + name + "&kredit=" + s + "&n=" + n;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</SCRIPT>
|
|
||||||
</HEAD>
|
</HEAD>
|
||||||
<body>
|
<body>
|
||||||
<div style="float: right;">
|
<div style="float: right;">
|
||||||
@ -253,7 +249,8 @@ switch ($shopCategoryTypeNumber) {
|
|||||||
|
|
||||||
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();
|
||||||
|
$ii->printControls('marketput');?>
|
||||||
<form method="post">
|
<form method="post">
|
||||||
<input placeholder="Цена" name="cost">
|
<input placeholder="Цена" name="cost">
|
||||||
<br><input type="submit" name="puttomarket" value="Cдать в магазин">
|
<br><input type="submit" name="puttomarket" value="Cдать в магазин">
|
||||||
|
26
test.php
26
test.php
@ -15,16 +15,16 @@ require_once 'config.php';
|
|||||||
# $items = []; foreach(фетч того ебучего массива as $value) {$items[$value['id']] = $value}
|
# $items = []; foreach(фетч того ебучего массива as $value) {$items[$value['id']] = $value}
|
||||||
|
|
||||||
$iteminfo =[];
|
$iteminfo =[];
|
||||||
$result = db::c()->query('SELECT `shop`.*,
|
//$result = db::c()->query('SELECT `shop`.*,
|
||||||
`magic`.`name` AS `magic_name`,
|
// `magic`.`name` AS `magic_name`,
|
||||||
`magic`.`chanse` AS `magic_chanse`,
|
// `magic`.`chanse` AS `magic_chanse`,
|
||||||
`magic`.`time` AS `magic_time`,
|
// `magic`.`time` AS `magic_time`,
|
||||||
`magic`.`file` AS `magic_file`,
|
// `magic`.`file` AS `magic_file`,
|
||||||
`magic`.`targeted` AS `magic_targeted`,
|
// `magic`.`targeted` AS `magic_targeted`,
|
||||||
`magic`.`needcharge` AS `magic_needcharge`,
|
// `magic`.`needcharge` AS `magic_needcharge`,
|
||||||
`magic`.`img` AS `magic_img`
|
// `magic`.`img` AS `magic_img`
|
||||||
|
//
|
||||||
FROM `shop` LEFT JOIN `magic` ON `magic` = `magic`.`id` WHERE count > 0 LIMIT 25');
|
//FROM `shop` LEFT JOIN `magic` ON `magic` = `magic`.`id` WHERE count > 0 LIMIT 25');
|
||||||
$result2 = db::c()->query('SELECT `inventory`.*,
|
$result2 = 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`,
|
||||||
@ -33,9 +33,9 @@ $result2 = db::c()->query('SELECT `inventory`.*,
|
|||||||
`magic`.`targeted` AS `magic_targeted`,
|
`magic`.`targeted` AS `magic_targeted`,
|
||||||
`magic`.`needcharge` AS `magic_needcharge`,
|
`magic`.`needcharge` AS `magic_needcharge`,
|
||||||
`magic`.`img` AS `magic_img` FROM `inventory` LEFT JOIN `magic` ON `magic` = `magic`.`id` WHERE owner = 11263');
|
`magic`.`img` AS `magic_img` FROM `inventory` LEFT JOIN `magic` ON `magic` = `magic`.`id` WHERE owner = 11263');
|
||||||
while ($row = $result->fetch_assoc()) {
|
//while ($row = $result->fetch_assoc()) {
|
||||||
$iteminfo[] = new ShopItem($row);
|
// $iteminfo[] = new ShopItem($row);
|
||||||
}
|
//}
|
||||||
|
|
||||||
while ($row = $result2->fetch_assoc()) {
|
while ($row = $result2->fetch_assoc()) {
|
||||||
$iteminfo[] = new InventoryItem($row);
|
$iteminfo[] = new InventoryItem($row);
|
||||||
|
Loading…
Reference in New Issue
Block a user