This commit is contained in:
Igor Barkov [iwork]
2019-02-15 17:00:01 +02:00
parent f61dd3f527
commit 313870a1fc
3 changed files with 55 additions and 47 deletions
+35 -24
View File
@@ -34,33 +34,44 @@ class ShopItem extends Item
*/
public function printControls($shopType = false)
{
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;
}
if ($shopType === 'marketput') {
echo <<<BTN
<form method="post">
<input placeholder="Цена" name="cost">
<input type="hidden" name="putId" value="{$this->id}">
<br><input type="submit" name="putToMarket" value="Cдать в магазин">
</form>
BTN;
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}"
onclick="location='{$btnLink}'">
BTN;
if ($this->count > 0) echo "<br><small>В наличии: {$this->count} штук</small>";
if ($this->count > 0) echo "<br><small>В наличии: {$this->count} штук</small>";
}
}
}