<?


include_once 'inc/fish/change_fish.php';
include_once 'inc/fish/change_soil.php';
include_once 'inc/fish/spond_all.php';
include_once 'inc/fish/spond.php';
include_once 'inc/fish/harvest_all.php';
include_once 'inc/fish/harvest.php';
include_once 'inc/fish/seat_all.php';
include_once 'inc/fish/seat.php';
include_once 'inc/fish/soil_all.php';
include_once 'inc/fish/soil.php';
include_once 'inc/fish/water_all.php';
include_once 'inc/fish/water.php';
include_once 'inc/fish/clean_grounds.php';
include_once 'inc/fish/new_pond.php';


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

if ($ku['komp']==0){
echo "<div class='event'><h1>Пруды
<a href='?ozero&komp'><img title='Компактный вид' width='16' height='16' src='images/icons/down.png' alt='o'></a>

<a href='?ozero&reflesh=".rand(99999,99999999)."'><img title='Обновить' width='16' height='16' src='images/icons/refresh.png' alt='o'></a>&nbsp; ";
if($ku['hydropinics_time']>$time)echo "<a class='epic' href='?shop=hydropinics'><img title='Гидропоника' width='16' height='16' src='images/icons/hydropinics.png' alt='o'></a>&nbsp; ";
if($ku['scarecrow_time']>$time)echo "<a class='epic' href='?shop=scarecrow'><img title='Пугало' width='16' height='16' src='images/icons/scarecrow.png' alt='o'></a>&nbsp; ";
if($ku['time_shmel']>$time)echo "<a href='?shop=helicopter&1'><img title='Шмель' width='16' height='16' alt='o' src='images/icons/heli1n.png'></a>&nbsp; ";
if($ku['time_yastreb']>$time)echo "<a class='epic' href='?shop=helicopter&2'><img title='Ястреб' width='16' height='16' alt='o' src='images/icons/heli2n.png'></a>&nbsp; ";
if($ku['time_drakon']>$time)echo "<a class='epic' href='?shop=helicopter&3'><img title='Дракон' width='16' height='16' alt='o' src='images/icons/heli3n.png'></a> ";
echo "</h1></div>";}


if ($ku['komp']==1){
echo "<div><h1>Пруды</h1></div><div class='content'>";
echo "<div class='block'> <img width='16' height='16' src='images/icons/refresh.png' alt='o'> <a href='?ozero&reflesh=".rand(99999,99999999)."'>Обновить</a>";

if($ku['hydropinics_time']>$time)echo "<li><img width='16' height='16' src='images/icons/hydropinics.png' alt='o'> <a class='epic' href='?shop=hydropinics'>Гидропоника</a><span class='minor'><span> $ku[hydropinics_type]%</span> на <span>".time_left($ku['hydropinics_time']-$time)."</span></span></li>";

if($ku['scarecrow_time']>$time)echo "<li><img width='16' height='16' src='images/icons/scarecrow.png' alt='o'> <a class='epic' href='?shop=scarecrow'>Пугало</a><span class='minor'> на <span>".time_left($ku['scarecrow_time']-$time)."</span></span></li>";

if($ku['time_shmel']>$time)echo "<li><img width='16' height='16' alt='o' src='images/icons/heli1n.png'> <a class='epic' href='?shop=helicopter&1'>Шмель</a><span class='minor'> на <span>".time_left($ku['time_shmel']-$time)."</span></span></li>";

if($ku['time_yastreb']>$time)echo "<li><img width='16' height='16' alt='o' src='images/icons/heli2n.png'> <a class='epic' href='?shop=helicopter&2'>Ястреб</a><span class='minor'> на <span>".time_left($ku['time_yastreb']-$time)."</span></span></li>";

if($ku['time_drakon']>$time)echo "<li><img width='16' height='16' alt='o' src='images/icons/heli3n.png'> <a class='epic' href='?shop=helicopter&3'>Дракон</a><span class='minor'> на <span>".time_left($ku['time_drakon']-$time)."</span></span></li>";

echo "<li><a href='?ozero&komp'><img width='16' height='16' src='images/icons/up.png' alt='o'> Компактный вид</a></li>";
echo "</div></div>";
}

/*
echo "<div class='event'><h1>Пруды <a href='?ozero&reflesh=".rand(99999,99999999)."'><img width='16' height='16' src='images/icons/refresh.png' alt='o'></a> ";
if($ku['hydropinics_time']>$time)echo "<a class='epic' href='?shop=hydropinics'><img width='16' height='16' src='images/icons/hydropinics.png' alt='o'></a> ";
if($ku['scarecrow_time']>$time)echo "<a class='epic' href='?shop=scarecrow'><img width='16' height='16' src='images/icons/scarecrow.png' alt='o'></a> ";
if($ku['dog_time']>$time)echo "<a class='epic' href='?shop=dog'><img width='16' height='16' src='images/icons/dog.png' alt='o'></a> ";
if($ku['time_shmel']>$time)echo "<a href='?shop=helicopter&1'><img width='16' height='16' alt='o' src='images/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='images/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='images/icons/heli3n.png'></a> ";
echo "</h1></div>";
*/

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='content'>";
echo "<div class='block'>";

////Разобьем на логические части


////Эффекты
////Конец эффектов

////Массовые мероприятия )))
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `$db_base`.`kolhoz_pond` WHERE `id_user` = '$ku[id]' AND (`time` < '$time' OR `time` = '$time') AND `id_plant` != '0'"),0)!=0 && $ku['catchfish']>0)echo "<div><img width='16' height='16' src='images/fish/ss-hrvst.png' alt='o'> <a href='?ozero&catchfish_all'>Выловить все</a></div>";


if(mysql_result(mysql_query("SELECT COUNT(*) FROM `$db_base`.`kolhoz_pond` 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['sponder']>0)echo "<div><img width='16' height='16' src='images/fish/ss-dg.png' alt='o'> <a href='?ozero&water_all'>Почистить все</a></div>";

if(mysql_result(mysql_query("SELECT COUNT(*) FROM `$db_base`.`kolhoz_pond` WHERE `id_user` = '$ku[id]' AND `id_plant` = '0' AND `cultivator` = '1'"),0)!=0 && $ku['catchfish']>0)echo "<div><img width='16' height='16' src='images/fish/ss-hrvst.png' alt='o'> <a href='?ozero&seat_all'>Запустить малька</a></div>";

if(mysql_result(mysql_query("SELECT COUNT(*) FROM `$db_base`.`kolhoz_pond` WHERE `id_user` = '$ku[id]' AND `id_plant` = '0' AND (`time` = '$time' OR `time` < '$time') AND `cultivator` = '0'"),0)!=0 && $ku['sponder']>0)echo "<div><img width='16' height='16' src='images/fish/ss-dg.png' alt='o'> <a href='?ozero&spond_all'>Очистить все</a></div>";
echo "<ul>";

////ПРУДЫ


$q=mysql_query("SELECT * FROM `$db_base`.`kolhoz_pond` WHERE `id_user` = '$ku[id]'");
while($post=mysql_fetch_array($q))
{
echo "<li>";
if($post['id_plant']!=0 && mysql_result(mysql_query("SELECT COUNT(*) FROM `$db_base`.`kolhoz_fish` WHERE `id` = '$post[id_plant]'"),0)!=0)
$plant=mysql_fetch_array(mysql_query("SELECT * FROM `$db_base`.`kolhoz_fish` WHERE `id` = '$post[id_plant]'"));

echo "<li><img width='48' height='48' src='".(!isset($plant)?"".($post['cultivator']==1?"images/fish/ozero_chist.png":"images/fish/ozero_durty.png")."":"images/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>".($post['time']>$time?"<span class='small minor'> (Вылов через <span> ".time_left($post['time']-$time)."</span>)</span>":null)."")."";
echo "</div>";
echo "<div>";
if(isset($plant))
{
if($post['time']<=$time)
{
echo "<img width='16' height='16' src='images/fish/ss-hrvst.png' alt='o'> <a href='?ozero&catchfish=$post[id]'>Выловить рыбу</a>";
}
else
{

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='images/fish/ss-dg.png'> <a href='?ozero&water=$post[id]'>Убрать тину</a>":null)."":null)."")."</div>";
}
}
else
{
echo "<span>";
if($ku['last_fish']!=0 && mysql_result(mysql_query("SELECT COUNT(*) FROM `$db_base`.`kolhoz_fish` WHERE `id` = '$ku[last_fish]'"),0)!=0)
$lp=mysql_fetch_array(mysql_query("SELECT * FROM `$db_base`.`kolhoz_fish` WHERE `id` = '$ku[last_fish]'"));
echo "".($post['cultivator']==1?"<img width='16' height='16' src='images/fish/ss-hrvst.png' alt='o'> ".(isset($lp)?"<a href='?ozero&seat=$post[id]&select=$lp[id]'>Запустить <span>".hsc($lp['name'])."</span></a> ":"<a href='?ozero&seat=$post[id]'>Запустить малька</a>")."":"<img width='16' height='16' src='images/fish/ss-dg.png' alt='o'> <a href='?ozero&spond=$post[id]'><span style='title'>Убрать тину</span></a>")."";
echo "</span>";
}
if(isset($plant))unset($plant);
echo "</div><div style='clear:both'></div></li>";
}
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `$db_base`.`kolhoz_pond` WHERE `id_user` = '$ku[id]'"),0)<20)echo "<li><img width='48' height='48' src='images/fish/ozero_chist.png' alt='o' class='portrait'><div><span class='title'>Новый пруд</span></div><div><img width='16' height='16' src='images/icons/cart.png' alt='o'> <a href='?ozero&new_pond'>Купить</a> за <span class='title'><img width='16' height='16' src='images/icons/ruby.png' alt='o'><span>".cpg(mysql_result(mysql_query("SELECT COUNT(*) FROM `$db_base`.`kolhoz_pond` WHERE `id_user` = '$ku[id]'"),0))."</span> рубинов</span></div><div style='clear:both'></div></li>";

if($ku['last_plant']!=0 && mysql_result(mysql_query("SELECT COUNT(*) FROM `$db_base`.`kolhoz_plant` WHERE `id` = '$ku[last_plant]'"),0)!=0)
$lp=mysql_fetch_array(mysql_query("SELECT * FROM `$db_base`.`kolhoz_fish` WHERE `id` = '$ku[last_fish]'"));

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


////Смена рыбы, прикормки
echo "<ul class='ptm'><li><img width='16' height='16' src='images/fish.png' alt='o'> <a href='?ozero&change_fish'>Выбрать мальков</a>: <span>".(isset($lp)?"".hsc($lp['name'])."":"-")."</span></li>";



echo "".($ku['time_fp']>$time?"<li><img width='16' height='16' src='images/icons/cross.png' alt='o'> 
До бесплатной очистки: <span>".time_left($ku['time_fp']-$time)."</span></li>
<li><span><img width='16' height='16' src='images/fish/sc-clr-ll.png' alt='o'> <a href='?ozero&clean_ponds'><span>Очистить пруды</span></a> (<span>Стоимость</span>: <span><img width='16' height='16' src='images/icons/ruby.png' alt='o'> 
<span class='title'>".($ku['count_fp']*10)."</span></span>)</span></li>":"<li><img width='16' height='16' src='images/fish/sc-clr-ll.png' alt='o'> <a href='?ozero&clean_ponds'>Очистить пруды</a></li>")."</ul></div>";

include_once 'inc/foot.php';
?>