<?
if($ku['level']<40)header("Location:/ozero");
include_once 'inc/mypool/change_fish.php';
include_once 'inc/mypool/clean_pools.php';
include_once 'inc/mypool/sell_all.php';
include_once 'inc/mypool/sell.php';
include_once 'inc/mypool/soil_all.php';
include_once 'inc/mypool/soil.php';
include_once 'inc/mypool/incube_all.php';
include_once 'inc/mypool/incube.php';
include_once 'inc/mypool/new_pool.php';


if(isset($_GET['leave'])){
if(empty($ku['trofim_time'])){
mysql_query("UPDATE `kolhoz_user` SET `trofim_time` = '".($ku['trofim_leave']+time())."',`trofim_leave` = '0' WHERE `id` = '$ku[id]' LIMIT 1");
header("Location:/mypool/".passgen());
}
else{
$gtime=$ku['trofim_time']-$time;
mysql_query("UPDATE `kolhoz_user` SET `trofim_leave` = '$gtime',`trofim_time` = '' WHERE `id` = '$ku[id]' LIMIT 1");
header("Location:/mypool/".passgen());

}
}

require_header ('Пруды');
if(isset($_SESSION['cp']))
{
echo "<div class='feedback'><ul class='feedbackPanel'><li class='feedbackPanelINFO'><span class='feedbackPanelINFO'>Бесплатная очистка пруда будет доступна через ".time_left($ku['time_cp']-$time)."</span></li></ul></div>";
unset($_SESSION['cp']);
}
echo "<div class='content'>";
echo "<div class='block'>";
echo "<div><img width='16' height='16' src='images/icons/refresh.png' alt='*'> <a href='/mypool/reflesh/".rand(99999,99999999)."'>Обновить</a></div>";

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


////Эффекты
if($ku['scarecrow_time']>$time)echo "<li><img width='16' height='16' src='images/icons/scarecrow.png' alt='*'> <a class='epic' href='/shop-scarecrow'>Пугало</a><span class='minor'> на <span>".time_left($ku['scarecrow_time']-$time)."</span></span></li>";
if($ku['dog_time']>$time)echo "<li><img width='16' height='16' src='images/icons/dog.png' alt='*'> <a class='epic' href='/shop-dog'>Собака</a><span class='minor'> $ku[dog_type]% на <span>".time_left($ku['dog_time']-$time)."</span></span></li>";
if($ku['time_drakon']>$time)echo "<li><img width='16' height='16' alt='*' 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>";
if($ku['money2x_time']>$time)echo "<li><img width='30'  alt='o' src='pavelgrey/img/2xmoney.png'> <a class='epic' href='/payment'>Двойной доход</a><span class='minor'> на <span>".time_left($ku['money2x_time']-$time)."</span></span></li>";

if($ku['trofim_time']>$time)echo "<li><img width='16' height='16' alt='' src='images/icons/fisherman.png'> <a class='epic' href='/shop-worker/id-2'>Работник Трофим</a><span class='minor'> на <span>".time_left($ku['trofim_time']-$time)."</span></span></li><li><img width='16' height='16' alt='' src='images/icons/bell.png'> <a class='epic' href='mypool/leave'>Уволить работника</a>";
if(!empty($ku['trofim_leave']))echo "<li><img width='16' height='16' alt='' src='images/icons/bell.png'> <a class='epic' href='/mypool/leave'>Вызвать работника</a>";
////Конец эффектов

////Массовые мероприятия )))
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_pool` WHERE `id_user` = '$ku[id]' AND (`time` < '$time' OR `time` = '$time') AND `id_fish` != '0'"),0)!=0 && $ku['autocrane']>0)echo "<div><img width='16' height='16' src='/images/fish/ss-dg.png' alt='*'> <a href='/mypool/sell_all'>Продать все</a></div>";

if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_pool` WHERE `id_user` = '$ku[id]' AND (`time_soil` = '$time' OR `time_soil` < '$time') AND `id_fish` != '0' AND `time` > '$time'"),0)!=0 && $ku['fishfooder']>0)echo "<div><img width='16' height='16' src='/images/icons/avtofooder.png' alt='*'> <a href='/mypool/soil_all'>Покормить всех</a></div>";

if(!empty($ku['last_pool']))$lp=mysql_fetch_array(mysql_query("SELECT `tname`,`name` FROM `kolhoz_pool_plant` WHERE `id`='$ku[last_pool]'"));
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_pool` WHERE `id_user` = '$ku[id]' AND `id_fish` = '0'"),0)!=0 && $ku['incubator']>0)echo "<div><img width='16' height='16' src='images/fish/ss-hrvst.png' alt='*'> <a href='/mypool/incube_all'> Разводить ".(!empty($ku['last_pool'])?"$lp[0]":"малька")."</a></div>";

echo "<ul><ul class='ptm'></ul>";

////ПРУДЫ

if($ku['compact']==1)$ku['str']=5;
if($ku['compact']==0)$ku['str']=500;
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_pool` WHERE `id_user` = '$ku[id]'"),0); 
if ($k_post==0) 
{ 
echo "Список пуст..."; 
} 
$k_page=k_page($k_post,$ku['str']); 
$page=page($k_page); 
$start=$ku['str']*$page-$ku['str']; 
$num=($page-1)*$ku['str']; 
$q=mysql_query("SELECT * FROM `kolhoz_pool` WHERE `id_user` = '$ku[id]' ORDER BY `id` DESC LIMIT $start, $ku[str]"); 
while($post=mysql_fetch_array($q))
{
echo "<li>";
if(empty($post['id_fish'])){
echo"<img width='48' height='48' src='images/empty.jpg' alt='*' class='portrait'><div></div>";
echo "<div><span class='title'>Пустой пруд</span></div>";
echo '<div>'.(isset($lp)?'<img width="16" height="16" src="/images/fish/ss-hrvst.png" alt="*"/> <a href="/mypool/incube-'.$post['id'].'">Разводить '.$lp[0].'</a>,':null).' <img width="16" height="16" src="/images/fish/ss-dg.png" alt="*"/> <a href="/mypool/change_fish">выбрать</a></div>';
}else{
$plant=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_pool_plant` WHERE `id`='$post[id_fish]'"));
echo"<img width='48' height='48' src='images/fish/pool/$plant[id].png' alt='*' class='portrait'><div></div>";
echo "<div><span class='title'>$plant[name]</span>".($post['time']<$time?"<br/><img width='16' height='16' src='/images/fish/ss-dg.png' alt='*'> <a href='/mypool/sell-$post[id]'>Продать</a>":"<span class='small minor'> (Вырастет через ".(time_left($post['time']-$time)).")<br/> ".($post['time_soil']<=$time?"</span><span><img width='16' height='16' src='images/icons/avtofooder.png' alt='*'> <a href='/mypool/soil-$post[id]'>Покормить</a>":"Кормление через ".(time_left($post['time_soil']-$time))."")."</span>")."</div>";
unset($plant);
}


echo "<div style='clear:both'></div></li>";
}
if ($k_page>1)str("/?mypool&",$k_page,$page); // Вывод страниц 

if($mypool<25 || ($ku['level']>=50 && $mypool<35) || ($ku['level']>=60 && $mypool<40))echo "<li><img width='48' height='48' src='images/empty.jpg' alt='o' class='portrait'><div><span class='title'>Новый пруд</span></div><div><img width='16' height='16' src='images/icons/cart.png' alt='*'> <a href='/mypool/new_pool'>Купить</a> за <span class='title'><img width='16' height='16' src='images/icons/ruby.png' alt='*'><span>$cena</span> рубинов</span></div><div style='clear:both'></div></li>";

echo "<ul class='ptm'>";

echo "<li class='ptm'></li>";
echo '<li>
<img width="16" height="16" src="/images/fish/ss-dg.png" alt="*"/> <a href="/mypool/change_fish">Сменить рыбу</a>'.(isset($lp[1])?': <span>'.$lp[1].'</span>':null).'
</li>';
echo "".($ku['time_pp']>$time?"<li><img width='16' height='16' src='images/icons/cross.png' alt='*'> 
До бесплатной очистки: <span>".time_left($ku['time_pp']-$time)."</span></li>
<li><span><img width='16' height='16' src='images/icons/cross.png' alt='*'> <a href='/mypool/clean_pools'><span>Очистить пруды</span></a> (<span>Стоимость</span>: <span><img width='16' height='16' src='images/icons/ruby.png' alt='*'> 
<span class='title'>".($ku['count_pp']*10)."</span></span>)</span></li>":"<li><img width='16' height='16' src='images/icons/cross.png' alt='o'> <a href='/mypool/clean_pools'>Очистить пруды</a></li>")."</ul></div>";

include_once 'inc/foot.php';
?>