<?
if(isset($_GET['f_myfarm']) && isset($_GET['harvest']) && intval($_GET['harvest'])!=NULL && mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_ground_f` WHERE `id` = '".intval($_GET['harvest'])."' AND `id_user` = '$ku[id]' AND `id_plant` != '0'"),0)!=0)
{

$ground=mysql_fetch_array(mysql_querll("SELECT * FROM `kolhoz_ground_f` WHERE `id` = '".intval($_GET['harvest'])."' AND `id_user` = '$ku[id]' AND `id_plant` != '0'"));

$plant=mysql_fetch_array(mysql_querll("SELECT * FROM `kolhoz_fish` WHERE `id` = '$ground[id_plant]'"));
if($ground['time']<=$time)
{


$count=$plant['count'];
$count_harvester_f_act=0;
$count_yastreb_act=0;
$count_greenhouse_act=0;
if(isset($harvester_f_act))$count_harvester_f_act=floor(($count/100)*$harvester_f_act);
if(isset($yastreb_act))$count_yastreb_act=(($count/100)*300);
if(isset($greenhouse_act))$count_greenhouse_act=(($count/100)*$greenhouse_ps);
$count=$count+$count_harvester_f_act+$count_yastreb_act+$count_greenhouse_act;
$count=floor($count);


if($pw=mysql_fetch_array(mysql_querll("SELECT * FROM `kolhoz_warehouse_f` WHERE `id_user` = '$ku[id]' AND `id_plant` = '$plant[id]' AND `arena` = '0'")))
{
mysql_querll("UPDATE `kolhoz_warehouse_f` SET `count` = '".($pw['count']+$count)."' WHERE `id` = '$pw[id]'");
}
else mysql_querll("INSERT INTO `kolhoz_warehouse_f` SET `id_plant` = '$plant[id]', `id_user`  = '$ku[id]', `count` = '$count', `arena` = '0'");
$_SESSION['fish']=$count;


//mysql_querll("UPDATE `kolhoz_user` SET `sadovod` = '".($ku['sadovod']+$count)."' WHERE `id` = '$ku[id]'");
mysql_querll("UPDATE `kolhoz_ground_f` SET `id_plant` = '0', `soil` = '0', `cultivator` = '0' WHERE `id` = '".intval($_GET['harvest'])."' LIMIT 1");
header("Location:?f_myfarm&".passgen());
}
else header("Location:?f_myfarm&".passgen());
exit;
}
?>