Now you can not change price of item without taking it back from shop
This commit is contained in:
parent
647ddb4221
commit
d08655b9ed
@ -22,7 +22,7 @@ $itemCost = filter_input(INPUT_GET, $_GET['kredit'], FILTER_VALIDATE_INT, ['opti
|
||||
$itemId = filter_input(INPUT_GET, $_GET['n'], FILTER_VALIDATE_INT, ['options' => ['min_range' => 1]]);
|
||||
$returningItemId = filter_input(INPUT_GET, $_GET['back'], FILTER_VALIDATE_INT, ['options' => ['min_range' => 1]]);
|
||||
|
||||
if ($get == 'sale' && $itemCost && $itemId) {
|
||||
if ($itemCost && $itemId) {
|
||||
$commission = ceil($itemCost / 10); # 10% от суммы с округлением вверх.
|
||||
if ($user['money'] > $commission) {
|
||||
$dress = db::c()->query('SELECT `name`,`duration`,`maxdur` FROM `inventory` WHERE `dressed` = 0 AND `id` = ?i AND `owner` = ?i', $itemId, $_SESSION['uid'])->fetch_assoc();
|
||||
@ -36,11 +36,6 @@ if ($get == 'sale' && $itemCost && $itemId) {
|
||||
} else $status = "У вас не хватает " . $commission - $user['money'] . " кр. чтобы оплатить комиссию!";
|
||||
}
|
||||
|
||||
|
||||
if ($get == 'unsale') {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ($returningItemId) {
|
||||
$dress = db::c()->query('SELECT `name`,`duration`,`maxdur` FROM `inventory` WHERE `dressed` = 0 AND `setsale` > 0 AND `id` = ?i AND `owner` = ?i', $returningItemId, $_SESSION['uid'])->fetch_assoc();
|
||||
if (db::c()->getAffectedRows()) {
|
||||
@ -107,28 +102,6 @@ if (($_GET['set'] OR $_POST['set'])) {
|
||||
}
|
||||
}
|
||||
|
||||
if ($get == 'sale' && $_GET['kredit'] && $_GET['id']) {
|
||||
if ((is_numeric($_GET['kredit']) && $_GET['kredit'] > 0) && (is_numeric($_GET['id']) && $_GET['id'] > 0)) {
|
||||
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `dressed`=0 AND `id` = '{$_GET['id']}' AND `owner` = '{$_SESSION['uid']}' AND `setsale` > 0 LIMIT 1;"));
|
||||
if ($dress['id']) {
|
||||
if ($user['money'] >= 0.1) {
|
||||
mysql_query("UPDATE `inventory` SET `setsale` = '" . $_GET['kredit'] . "' WHERE `id` = '{$_GET['id']}' AND `owner` = '{$_SESSION['uid']}' LIMIT 1;");
|
||||
|
||||
mysql_query("UPDATE `users` set `money` = `money`- '0.1' WHERE id = {$_SESSION['uid']}");
|
||||
mysql_query("INSERT INTO `delo` (`id` , `author` ,`pers`, `text`, `type`, `date`) VALUES ('','0','{$_SESSION['uid']}','\"" . $user['login'] . "\" заплатил 0.1 кр за смену цены на предмет \"" . $dress['name'] . "\" id:(cap" . $dress['id'] . ") [" . $dress['duration'] . "/" . $dress['maxdur'] . "] в комиссионке ',1,'" . time() . "');");
|
||||
$user['money'] = $user['money'] - 0.1;
|
||||
echo "<font color=red><b>Вы изменили цену \"{$dress['name']}\" на {$_GET['kredit']} кр.</b></font>";
|
||||
} else {
|
||||
echo "<font color=red><b>У вас недостаточно денег на выполнение операции.</b></font>";
|
||||
}
|
||||
} else {
|
||||
echo "<font color=red><b>Предмет не найден.</b></font>";
|
||||
}
|
||||
} else {
|
||||
echo "<font color=red><b>Не надо так делать</b></font>";
|
||||
}
|
||||
}
|
||||
|
||||
$shopCategoryTypeNumber = empty($_GET['otdel']) ?: $_GET['otdel'];
|
||||
switch ($shopCategoryTypeNumber) {
|
||||
default:
|
||||
@ -247,36 +220,37 @@ switch ($shopCategoryTypeNumber) {
|
||||
<?php
|
||||
}
|
||||
} elseif ($_REQUEST['sale']) {
|
||||
echo "<TR bgcolor=#C7C7C7><TD align=center colspan=2>Комиссия за услуги магазина составляет 10% от цены, по которой вы предлагаете предмет.</TD></TR>";
|
||||
echo "<TR bgcolor=#C7C7C7><th colspan=2>Комиссия за услуги магазина составляет 10% от цены, по которой вы предлагаете предмет.</th></TR>";
|
||||
$data = db::c()->query('SELECT * FROM `inventory` WHERE `setsale` = 0 AND `dressed` = 0 AND `present` = "?s" AND `owner` = ?i ORDER BY `update` DESC ', '', $_SESSION['uid']);
|
||||
|
||||
while ($row = $data->fetch_assoc()) {
|
||||
echo "<TR bgcolor={$color}><TD align=center style='width:150px'><IMG SRC=\"i/sh/{$row['img']}\" BORDER=0>";
|
||||
?>
|
||||
<BR>
|
||||
<A onclick="sale('1', '<?= $row['name'] ?>', '<?= $row['id'] ?>', '<?= $row['cost'] ?>');"
|
||||
HREF="#">cдать в магазин</A>
|
||||
</TD>
|
||||
<TR>
|
||||
<TD align=center style="width:150px"><IMG SRC="i/sh/<?= $row['img'] ?>">
|
||||
<BR>
|
||||
<A onclick="sale('1', '<?= $row['name'] ?>', '<?= $row['id'] ?>', '<?= $row['cost'] ?>');"
|
||||
HREF="#">cдать в магазин</A>
|
||||
</TD>
|
||||
<TD valign=top>
|
||||
<?php showitem($row); ?>
|
||||
</TD>
|
||||
</TR>
|
||||
<?php
|
||||
echo "<TD valign=top>";
|
||||
showitem($row);
|
||||
echo "</TD></TR>";
|
||||
}
|
||||
} elseif ($_REQUEST['unsale']) {
|
||||
$data = db::c()->query('SELECT * FROM `inventory` WHERE `setsale` > 0 AND `dressed` = 0 AND `owner` = ?i ORDER BY `update` DESC', $_SESSION['uid']);
|
||||
|
||||
while ($row = $data->fetch_assoc()) {
|
||||
echo "<TR bgcolor={$color}><TD align=center style='width:150px'><IMG SRC=\"i/sh/{$row['img']}\" BORDER=0>";
|
||||
?>
|
||||
<BR><A HREF="?back=<?= $row['id'] ?>&sid=&unsale=1">забрать</A>
|
||||
<BR>
|
||||
<A onclick="chsale('1', '<?= $row['name'] ?>', <?= $row['id'] ?>, '1', '<?= $row['setsale'] ?>')"
|
||||
HREF="#">сменить цену<BR>за 0.1 кр.</A>
|
||||
</TD>
|
||||
<TR>
|
||||
<TD align=center style="width:150px"><IMG SRC="i/sh/<?= $row['img'] ?>">
|
||||
<BR><A HREF="?back=<?= $row['id'] ?>&sid=&unsale=1">забрать</A>
|
||||
</TD>
|
||||
<TD valign=top>
|
||||
<?php showitem($row); ?>
|
||||
</TD>
|
||||
</TR>
|
||||
<?php
|
||||
echo "<TD valign=top>";
|
||||
showitem($row);
|
||||
echo "</TD></TR>";
|
||||
}
|
||||
} else {
|
||||
$data = mysql_query("SELECT DISTINCT `img`, `name`, `nalign`,`massa` FROM `inventory` WHERE `dressed`=0 AND `setsale` > 0 AND `present` = '' AND `otdel` = '" . $_GET['otdel'] . "' GROUP BY `img` ORDER by `cost` ASC");
|
||||
|
Loading…
Reference in New Issue
Block a user