<?

if(mysql_result(mysql_querll("SELECT COUNT(`id`) FROM `kolhoz_ground_f` WHERE `id_user` = '$ku[id]'"),0)<4){
mysql_querll("INSERT INTO `kolhoz_ground_f` SET `id_user` = '$ku[id]', `cultivator` = '1'");
mysql_querll("INSERT INTO `kolhoz_ground_f` SET `id_user` = '$ku[id]', `cultivator` = '1'");
mysql_querll("INSERT INTO `kolhoz_ground_f` SET `id_user` = '$ku[id]', `cultivator` = '1'");
mysql_querll("INSERT INTO `kolhoz_ground_f` SET `id_user` = '$ku[id]', `cultivator` = '1'");
}
if(isset($_SESSION['fp'])){echo "<div class='feedback'><ul class='feedbackPanel'><li class='feedbackPanelINFO'><span class='feedbackPanelINFO'>Бесплатная очистка прудов будет доступна через ".time_left($ku['time_fp']-$time)."</span></li></ul></div>";unset($_SESSION['fp']);}

echo "<div class='event'><h1>Пруды</h1></div>";

if($ku['level']<30)
{
echo "<div class='content'>";
echo "<div class='block'>";
echo'<img src="img/icons/owibochka.gif" alt="*"> Пруды доступны со 30-го уровня!';
include_once 'inc/foot.php';
echo "</div></div>";
exit;
}
if(isset($_GET['f_myfarm']) && $_GET['f_myfarm']=='sv')
{
mysql_querll("UPDATE `kolhoz_user` SET `sv` = '1' WHERE `id` = '$ku[id]'");
header("Location:?f_myfarm");
}
if(isset($_GET['f_myfarm']) && $_GET['f_myfarm']=='rv')
{
mysql_querll("UPDATE `kolhoz_user` SET `sv` = '0' WHERE `id` = '$ku[id]'");
header("Location:?f_myfarm");
}

if(isset($_GET['vidok'])){
mysql_query("UPDATE `kolhoz_user` SET `vidok` = '".($ku['vidok']==1?"0":"1")."' WHERE `id` = '$ku[id]'");
header("Location:?f_myfarm");
}

include_once 'inc/f_myfarm/change_plant.php';
include_once 'inc/f_myfarm/change_soil.php';
include_once 'inc/f_myfarm/cultivator_all.php';
include_once 'inc/f_myfarm/cultivator.php';
include_once 'inc/f_myfarm/harvest_all.php';
include_once 'inc/f_myfarm/harvest.php';
include_once 'inc/f_myfarm/seat_all.php';
include_once 'inc/f_myfarm/seat.php';
include_once 'inc/f_myfarm/soil_all.php';
include_once 'inc/f_myfarm/soil.php';
include_once 'inc/f_myfarm/water_all.php';
include_once 'inc/f_myfarm/water.php';
include_once 'inc/f_myfarm/clean_ponds.php';
include_once 'inc/f_myfarm/new_ground.php';
echo "<div class='content'>";
echo "<div class='block'>";







echo "<div class='block'>".($ku['vidok']==0?"<a href='?f_myfarm&vidok'>Компактный вид <img width='16' height='16' src='img/icons/right.png' alt='o'></a>":"<a href='?f_myfarm&vidok'><img width='16' height='16' src='img/icons/left.png' alt='o'>")."</a> ";
if($ku['vidok']==1){
echo "<a href='?f_myfarm&reflesh=".rand(99999,99999999)."'><img width='16' height='16' src='img/icons/obmen.png' alt='o'></a> ";
if($ku['hydropinics_time']>$time)echo "<a class='epic' href='?shop=hydropinics'><img width='16' height='16' src='img/icons/hydropinics.png' alt='o'></a> ";
if($ku['vetriak_time']>$time)echo "<a class='epic' href='?shop=vetriak'><img width='16' height='16' src='img/vetriak.png' alt='o'></a> ";
if($ku['scarecrow_time']>$time)echo "<a class='epic' href='?shop=scarecrow'><img width='16' height='16' src='img/icons/scarecrow.png' alt='o'></a> ";
if($ku['time_shmel']>$time)echo "<a class='epic' href='?shop=helicopter&1'><img width='16' height='16' alt='o' src='img/icons/heli1n.png'></a> ";
if($ku['time_yastreb']>$time)echo "<a class='epic' href='?shop=helicopter&2'><img width='16' height='16' alt='o' src='img/icons/heli2n.png'></a> ";
if($ku['time_drakon']>$time)echo "<a class='epic' href='?shop=helicopter&3'><img width='16' height='16' alt='o' src='img/icons/heli3n.png'></a> ";
if($ku['garden_time']>$time)echo "<a class='epic' href='?shop=gardener&id=".$ku['gardener']."'><img width='16' height='16' alt='' src='img/icons/gardener".$ku['gardener'].".png'></a> ";
}
echo "</div>";
if($ku['vidok']==0){
echo "<a href='?f_myfarm&reflesh=".rand(99999,99999999)."'><div class='block'><img width='16' height='16' src='img/icons/obmen.png' alt='o'> Обновить</a></div>";
//if($ku['garden_time']>$time)echo "<a class='epic' href='?shop=gardener&id=".$ku['gardener']."'><div class='block'><img width='16' height='16' alt='' src='img/icons/gardener".$ku['gardener'].".png'> Садовник ".$name."</a><span class='minor'> <span>".time_left($ku['garden_time']-$time)."</span></span></div>";
//if($ku['hydropinics_time']>$time)echo "<a class='epic' href='?shop=hydropinics'><div class='block'><img width='16' height='16' src='img/icons/hydropinics.png' alt='o'> Гидропоника</a> <span class='minor'> <b>$ku[hydropinics_type]%</b> <span>".time_left($ku['hydropinics_time']-$time)."</span></span></div>";
//if($ku['scarecrow_time']>$time)echo "<a class='epic' href='?shop=scarecrow'><div class='block'><img width='16' height='16' src='img/icons/scarecrow.png' alt='o'> Пугало</a><span class='minor'> <span>".time_left($ku['scarecrow_time']-$time)."</span></span></div>";
if($ku['vetriak_time']>$time)echo "<a class='epic' href='?shop=vetriak'><div class='block'><img width='16' height='16' src='img/vetriak.png' alt='o'> Ветряк</a><span class='minor'> <span>".time_left($ku['vetriak_time']-$time)."</span></span></div>";
if($ku['time_shmel']>$time)echo "<a class='epic' href='?shop=helicopter&1'><div class='block'><img width='16' height='16' src='img/icons/heli1n.png' alt='o'> Шмель</a> <span class='minor'> <span>".time_left($ku['time_shmel']-$time)."</span></span></div>";
if($ku['time_yastreb']>$time)echo "<a class='epic' href='?shop=helicopter&2'><div class='block'><img width='16' height='16' src='img/icons/heli2n.png' alt='o'> Ястреб</a><span class='minor'> <span>".time_left($ku['time_yastreb']-$time)."</span></span></div>";
if($ku['time_drakon']>$time)echo "<a class='epic' href='?shop=helicopter&3'><div class='block'><img width='16' height='16' src='img/icons/heli3n.png' alt='o'> Дракон</a><span class='minor'> <span>".time_left($ku['time_drakon']-$time)."</span></span></div>";
}


//массовые действия
if(mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_ground_f` WHERE `id_user` = '$ku[id]' AND (`time` < '$time' OR `time` = '$time') AND `id_plant` != '0'"),0)!=0 && $ku['harvester_f']>0)echo "<a href='?f_myfarm&harvest_all'><div class='block'><img width='16' height='16' src='img/fish/feed_feesh.png' alt='o'> Выловить всех</div></a>";
if(mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_ground_f` WHERE `id_user` = '$ku[id]' AND `soil` = '0' AND (`time_soil` = '$time' OR `time_soil` < '$time') AND `id_plant` != '0' AND `time` > '$time'"),0)!=0 && $ku['soiler_f']>0)echo "<a href='?f_myfarm&soil_all'><div class='block'><img width='16' height='16' src='img/fish/feed_feesh.png' alt='o'> Подкормить всех</div></a>";
if(mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_ground_f` WHERE `id_user` = '$ku[id]' AND `id_plant` != '0' AND (`time_water` = '$time' OR `time_water` < '$time') AND `time` > '$time' AND (`soil` = '0' AND `time_soil` > '$time' OR `soil` = '1')"),0)!=0 && $ku['irregate_f']>0)echo "<a href='?f_myfarm&water_all'><div class='block'><img width='16' height='16' src='img/icons/water.png' alt='o'> Аэрозировать все</div></a>";
if(mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_ground_f` WHERE `id_user` = '$ku[id]' AND `id_plant` = '0' AND `cultivator` = '1'"),0)!=0 && $ku['seeder_f']>0)echo "<a href='?f_myfarm&seat_all'><div class='block'><img width='16' height='16' src='img/fish/ss-hrvst.png' alt='o'> Запустить всех</div></a>";
if(mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_ground_f` WHERE `id_user` = '$ku[id]' AND `id_plant` = '0' AND (`time` = '$time' OR `time` < '$time') AND `cultivator` = '0'"),0)!=0 && $ku['cultivator_f']>0)echo "<a href='?f_myfarm&cultivator_all'><div class='block'><img width='16' height='16' src='img/fish/ss-dg.png' alt='o'> Очистить все</div></a>";



echo "<div class='block'>".($ku['sv']==0?"<img width='16' height='16' src='img/icons/up.png' alt='o'> <a href='?f_myfarm=sv'><font color='violet'>Свернуть</font></a>":"<img width='16' height='16' src='img/icons/down.png' alt='o'> <a href='?f_myfarm=rv'><font color='violet'>Развернуть</font>")."</a></div><div class='xr'></div>";


if($ku['sv']==1){
$q=mysql_querll("SELECT * FROM `kolhoz_ground_f` WHERE `id_user` = '$ku[id]' LIMIT 1");
}else{
$q=mysql_querll("SELECT * FROM `kolhoz_ground_f` WHERE `id_user` = '$ku[id]'");
}





while($post=mysql_fetch_array($q))
{
if($post['id_plant']!=0 && mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_fish` WHERE `id` = '$post[id_plant]'"),0)!=0)$plant=mysql_fetch_array(mysql_querll("SELECT * FROM `kolhoz_fish` WHERE `id` = '$post[id_plant]'"));

echo "<div class='block'><img width='48' height='48' src='".(!isset($plant)?"".($post['cultivator']==1?"img/fish/ozero_chist.png":"img/fish/ozero_durty.png")."":"img/fish/$plant[id].png")."' alt='o' class='portrait'>";
//echo "<div>";
echo "".(!isset($plant)?"<span class='title'>".($post['cultivator']==1?"Чистый пруд":"Грязный пруд")."</span>":"<span  class='title'>".hsc($plant['name'])."</span> <span>(".hsc($plant['count'])." кг)</span>".($post['time']>$time?"<br/><span class='small minor'> (Вылов через <span> ".time_left($post['time']-$time)."</span>)</span>":null)."")."<br/>";
//echo "</div>";
//echo "<div>";
if(isset($plant))
{
if($post['time']<=$time)
{
echo "<img width='16' height='16' src='img/fish/feed_feesh.png' alt='o'> <a href='?f_myfarm&harvest=$post[id]'>Выловить рыбу</a>";
echo "<div style='clear:both'></div>";
}
else
{
if($ku['last_soil_f']!=0 && mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_korm` WHERE `id` = '$ku[last_soil_f]'"),0)!=0)$ls=mysql_fetch_array(mysql_querll("SELECT * FROM `kolhoz_korm` WHERE `id` = '$ku[last_soil_f]'"));
echo "<div class='small minor'>".($post['time_soil']<=$time && $post['soil']==0 && $post['time']>$time?"<img width='16' height='16' src='img/fish/feed_feesh.png' alt='o'> ".(isset($ls)?"<a href='?f_myfarm&soil=$post[id]&select=$ls[id]'>Применить
<span>".hsc($ls['name'])."</span></a>, <a href='?f_myfarm&soil=$post[id]'><span>выбрать
корм</span></a>":"<a href='?f_myfarm&soil=$post[id]'>Подкормить</a>")."":"".($post['soil']==0 && $post['time']>$time?"Подкормить через ".time_left($post['time_soil']-$time)."":null)."")."</div>";
echo "<div class='small minor'>".($post['time_water']>$time && $post['time']>$time?"Аэрозия через ".time_left($post['time_water']-$time)."":"".($post['time']>$time?"".($post['soil']==0 && $post['time_soil']>$time || $post['soil']==1?"<img alt='' width='16' height='16' src='img/icons/water.png'> <a href='?f_myfarm&water=$post[id]'>Аэрозировать</a>":null)."":null)."")."</div>";
}
}
else
{
if($ku['last_plant_f']!=0 && mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_fish` WHERE `id` = '$ku[last_plant_f]'"),0)!=0)$lp=mysql_fetch_array(mysql_querll("SELECT * FROM `kolhoz_fish` WHERE `id` = '$ku[last_plant_f]'"));
echo "".($post['cultivator']==1?"<img width='16' height='16' src='img/fish/ss-hrvst.png' alt='o'> ".(isset($lp)?"<a href='?f_myfarm&seat=$post[id]&select=$lp[id]'>Запустить <span>".hsc($lp['name'])."</span></a>, <a href='?f_myfarm&seat=$post[id]'><span>выбрать малька</span></a>":"<a href='?f_myfarm&seat=$post[id]'>Запустить</a>")."":"<img width='16' height='16' src='img/fish/ss-dg.png' alt='o'> <a href='?f_myfarm&cultivator=$post[id]'><span style='title'>Убрать тину</span></a>")."";
echo "<div style='clear:both'></div>";
}
if(isset($plant))unset($plant);
echo "</div><div style='clear:both'></div>";
}



if(mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_ground_f` WHERE `id_user` = '$ku[id]'"),0)<200)echo "<div class='block'><img width='48' height='48' src='img/fish/ozero_chist.png' alt='o' class='portrait'><div><span class='title'>Новый пруд</span></div><div><img width='16' height='16' src='img/icons/cart.png' alt='o'> <a href='?f_myfarm&new_ground'>Купить</a> за <span class='title'><img width='16' height='16' src='img/icons/ruby.png' alt='o'><span>".cpg(mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_ground_f` WHERE `id_user` = '$ku[id]'"),0))."</span></div><div style='clear:both'></div></div>";

if($ku['last_plant_f']!=0 && mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_fish` WHERE `id` = '$ku[last_plant_f]'"),0)!=0)$lp=mysql_fetch_array(mysql_querll("SELECT * FROM `kolhoz_fish` WHERE `id` = '$ku[last_plant_f]'"));

if($ku['last_soil_f']!=0 && mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_korm` WHERE `id` = '$ku[last_soil_f]'"),0)!=0)$ls=mysql_fetch_array(mysql_querll("SELECT * FROM `kolhoz_korm` WHERE `id` = '$ku[last_soil_f]'"));

echo "<a href='?f_myfarm&change_plant'><div class='block'><img width='16' height='16' src='img/fish/ss-hrvst.png' alt='o'> Сменить мальков</a>: <span><b>".(isset($lp)?"".hsc($lp['name'])."":"-")."</b></span></div>";
echo "<a href='?f_myfarm&change_soil'><div class='block'><img width='16' height='16' src='img/fish/feed_feesh.png' alt='o'> Сменить корм</a>: <span><b>".(isset($ls)?"".hsc($ls['name'])."":"-")."</b></span></div>";





echo "".($ku['time_fp']>$time?"<div class='block'><img width='16' height='16' src='img/icons/ok_off.png' alt='o'> <font color='violet'>До бесплатной очистки</font>: <img width='14' height='14' src='img/icons/times.png' alt='o'> <b>".time_left($ku['time_fp']-$time)."</b></div><a href='?f_myfarm&clean_ponds'><div class='block'><img width='16' height='16' src='img/icons/ok_on.png' alt='o'> Очистить все пруды</a> (<img width='16' height='16' src='img/icons/ruby.png' alt='o'>
<span class='title'>".($ku['count_fp']*10)."</span></span>)</span>":"<a href='?f_myfarm&clean_ponds'><div class='block'><img width='16' height='16' src='img/icons/del.png' alt='o'> Очистить все пруды</a>")."</div>";



if(isset($mc))echo "<a href='?collective=$mc[id]&hangar'><div class='block'><img width='16' height='16' src='img/icons/heli4n.png' alt='o'> Вызвать вертолет</a></div>";


include_once 'inc/foot.php';
?>