Файл: ferma/inc/warehouse.php
Строк: 104
<?
?>
<div class="g1">Содержимое</div>
<?
echo "<div class='content'>";
echo "<div class='block'>";
if(isset($_GET['sell_all']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_warehouse` WHERE `id_user` = '$ku[id]'"),0)!=0)
{
$q=mysql_query("SELECT * FROM `kolhoz_warehouse` WHERE `id_user` = '$ku[id]'");
$cm=0;
while($post=mysql_fetch_array($q))
{
$plant=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_plant` WHERE `id` = '$post[id_plant]'"));
$m=floor(($plant['money']/$plant['count'])*$post['count']);
$cm=$cm+$m;
}
mysql_query("UPDATE `kolhoz_user` SET `money` = '".($ku['money']+$cm)."' WHERE `id` = '$ku[id]'");
mysql_query("DELETE FROM `kolhoz_warehouse` WHERE `id_user` = '$ku[id]'");
mysql_query("UPDATE `kolhoz_user` SET `umoney` = '$cm' WHERE `id` = '$ku[id]'");
if(isset($mc) && $mc['nalog']>0)
{
$nmoney=floor(($cm/100)*$mc['nalog']);
mysql_query("UPDATE `kolhoz_user` SET `money` = '".($ku['money']+$cm-$nmoney)."' WHERE `id` = '$ku[id]'");
mysql_query("INSERT INTO `kolhoz_collective_cash` SET `id_user` = '$ku[id]', `id_collective` = '$mc[id]', `count` = '$nmoney', `type` = 'money', `time` = '$time'");
mysql_query("UPDATE `kolhoz_collective` SET `money` = '".($mc['money']+$nmoney)."' WHERE `id` = '$mc[id]'");
}
header("Location:?warehouse&".passgen());
exit;
}
if(isset($_GET['sell']) && intval($_GET['sell'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_warehouse` WHERE `id_user` = '$ku[id]' AND `id` = '".intval($_GET['sell'])."'"),0)!=0)
{
$pw=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_warehouse` WHERE `id_user` = '$ku[id]' AND `id` = '".intval($_GET['sell'])."'"),0);
$plant=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_plant` WHERE `id` = '$pw[id_plant]'"));
$m=floor(($plant['money']/$plant['count'])*$pw['count']);
mysql_query("UPDATE `kolhoz_user` SET `money` = '".($ku['money']+$m)."' WHERE `id` = '$ku[id]'");
mysql_query("DELETE FROM `kolhoz_warehouse` WHERE `id` = '$pw[id]'");
mysql_query("UPDATE `kolhoz_user` SET `umoney` = '$m' WHERE `id` = '$ku[id]'");
if(isset($mc) && $mc['nalog']>0)
{
$nmoney=floor(($m/100)*$mc['nalog']);
mysql_query("UPDATE `kolhoz_user` SET `money` = '".($ku['money']+$m-$nmoney)."' WHERE `id` = '$ku[id]'");
mysql_query("INSERT INTO `kolhoz_collective_cash` SET `id_user` = '$ku[id]', `id_collective` = '$mc[id]', `count` = '$nmoney', `type` = 'money', `time` = '$time'");
mysql_query("UPDATE `kolhoz_collective` SET `money` = '".($mc['money']+$nmoney)."' WHERE `id` = '$mc[id]'");
}
header("Location:?warehouse&".passgen());
exit;
}
echo "<ul class='ptm'>";
$q=mysql_query("SELECT * FROM `kolhoz_warehouse` WHERE `id_user` = '$ku[id]' AND `arena` = '0'");
if(mysql_num_rows($q)==0)echo "<li>В складе нету овощей</li>";
$cm=0;
while($post=mysql_fetch_array($q))
{
$plant=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_plant` WHERE `id` = '$post[id_plant]'"));
$m=floor(($plant['money']/$plant['count'])*$post['count']);
echo "<font size='2'><li><div><img width='40' height='40' src='i/s1/$plant[id].png' alt='o' ><li><span class='title'>Название: ".hsc($plant['name'])."</span></li> <li>Количество: <span>$post[count] единиц(а)</span></li> <a href='?warehouse&sell=$post[id]'>Продать</a> в (местный магазин)<li>Прибыль: <img width='16' height='16' src='i/icons/money.png' alt='o'><span>$m (монет)</span>
</div></font></li>";
echo "<img src=i/hr.png width=100% height=2>";
$cm=$cm+$m;
}
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_warehouse` WHERE `id_user` = '$ku[id]'"),0)!=0)echo "<font size='2'><li><img alt='*' width='16' height='16' src='i/icons/money.png'> <a href='?warehouse&sell_all'>Продать всё</a> оптом в (местный магазин) <li>Прибыль: <img width='16' height='16' src='i/icons/money.png' alt='o'><span>$cm</span></font></li>";
echo "</ul></div>";
include_once 'inc/foot.php';
?>