<?php
if(isset($_GET['mywork']) && isset($_GET['harvest']) && intval($_GET['harvest'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `$db_base`.`kolhoz_mest` WHERE `id` = '".intval($_GET['harvest'])."' AND `id_user` = '$ku[id]' AND `id_plant` != '0'"),0)!=0)
{
$ground=mysql_fetch_array(mysql_query("SELECT * FROM `$db_base`.`kolhoz_mest` WHERE `id` = '".intval($_GET['harvest'])."' AND `id_user` = '$ku[id]' AND `id_plant` != '0'"));
$plant=mysql_fetch_array(mysql_query("SELECT * FROM `$db_base`.`kolhoz_works` WHERE `id` = '$ground[id_plant]'"));
if($ground['time']<=$time)
{
$money=$ku['money']+$plant['money'];
$money=floor($money);

mysql_query("UPDATE `$db_base`.`kolhoz_user` SET `money` = '$money',`umoney`='$plant[money]' WHERE `id` = '$ku[id]'");
/*if(isset($mc) && $mc['nalog']>0)
{
$money=$plant['money'];
$nmoney=floor(($money/100)*$mc['nalog']);
mysql_query("UPDATE `$db_base`.`kolhoz_user` SET `money` = '".($ku['money']+$money-$nmoney)."' WHERE `id` = '$ku[id]'");
mysql_query("UPDATE `$db_base`.`kolhoz_collective` SET `money` = '".($mc['money']+$nmoney)."' WHERE `id` = '$mc[id]'");
mysql_query("INSERT INTO `$db_base`.`kolhoz_collective_cash` SET `id_user` = '$ku[id]', `id_collective` = '$mc[id]', `count` = '$nmoney', `type` = 'money', `time` = '$time'");
}
$_SESSION['harvest']=$count;*/
mysql_query("UPDATE `$db_base`.`kolhoz_user` SET `master` = '".($ku['master']+1)."' WHERE `id` = '$ku[id]'");
mysql_query("UPDATE `$db_base`.`kolhoz_mest` SET `id_plant` = '0', `soil` = '0', `cultivator` = '0' WHERE `id` = '".intval($_GET['harvest'])."' LIMIT 1");
header("Location:?mywork&".passgen());
}
else header("Location:?mywork&".passgen());
exit;
}
if(isset($_GET['new_work']) && isset($_GET['ok']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `$db_base`.`kolhoz_mest` WHERE `id_user` = '$ku[id]'"),0)<6)
{
$cena=cpw(mysql_result(mysql_query("SELECT COUNT(*) FROM `$db_base`.`kolhoz_mest` WHERE `id_user` = '$ku[id]'"),0));
if($ku['rubies']>=$cena)
{
mysql_query("INSERT INTO `$db_base`.`kolhoz_mest` SET `id_user` = '$ku[id]'");
mysql_query("UPDATE `$db_base`.`kolhoz_user` SET `rubies` = '".($ku['rubies']-$cena)."' WHERE `id` = '$ku[id]'");
}
else
{
$rm=$cena-$ku['rubies'];
$_SESSION['no_rubies']=$rm;
}
header("Location:?mywork");
}
elseif(isset($_GET['new_work']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `$db_base`.`kolhoz_mest` WHERE `id_user` = '$ku[id]'"),0)<6)
{
echo '<div class="event"><h1>Подтверждение</h1></div><div class="content"><div class="block"><ul class="block"><li><span class="title">Вы уверены?</span></li><li class="pt"><img alt="" width="16" height="16" src="images/icons/tick.png"> <a href="?mywork&new_work&ok"><span>
Да, подтверждаю</span></a></li><li><img alt="" width="16" height="16" src="images/icons/cross.png"> <a href="?mywork"><span>
Нет, отказываюсь</span></a></li></ul></div>';
include_once 'inc/foot.php';
}
?>