<?
include_once 'inc/change_plant.php';
include_once 'inc/change_soil.php';
include_once 'inc/cultivator_all.php';
include_once 'inc/cultivator.php';
include_once 'inc/harvest_all.php';
include_once 'inc/harvest.php';
include_once 'inc/seat_all.php';
include_once 'inc/seat.php';
include_once 'inc/soil_all.php';
include_once 'inc/soil.php';
include_once 'inc/water_all.php';
include_once 'inc/water.php';
include_once 'inc/clean_grounds.php';
include_once 'inc/new_ground.php';
?>
<li><div class='block'><img src="images/icons/warehouse.png"> <a href="?myfarm<? echo (!isset($_GET['bonus'])?"&bonus":null)."";?>">Показать/Скрыть бонусы</a></div>
<?
if(isset($_GET['bonus']))
{
echo "<div class='block'>";
if($ku['hydropinics_time']>$time)echo "<img width='16' height='16' src='images/icons/hydropinics.png' alt='o'><span class='minor'> $ku[hydropinics_type]% на <span>".time_left($ku['hydropinics_time']-$time)."</span></span><br>";
if($ku['scarecrow_time']>$time)echo "<img width='16' height='16' src='images/icons/scarecrow.png' alt='o'><span class='minor'> <span>".time_left($ku['scarecrow_time']-$time)."</span></span><br>";
if($ku['time_shmel']>$time)echo "<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><br>";
if($ku['time_yastreb']>$time)echo "<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><br>";
if($ku['time_drakon']>$time)echo "<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><br>";
echo "</div>";
}
?>
</li>

<?

echo "<div class='block'><img width='16' height='16' src='images/icons/refresh.png' alt='o'> <a href='?myfarm&reflesh=".rand(99999,99999999)."'>Обновить</a></div>";
////ГРЯДКИ
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_ground` WHERE `id_user` = '$ku[id]' AND (`time` < '$time' OR `time` = '$time') AND `id_plant` != '0'"),0)!=0 && $ku['harvester']>0)echo "<div class='block'><img width='16' height='16' src='images/icons/plants.png' alt='o'> <a href='?myfarm&harvest_all'>Собрать все</a></div>";
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_ground` 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']>0)echo "<div class='block'><img width='16' height='16' src='images/icons/soil.png' alt='o'> <a href='?myfarm&soil_all'>Удобрить все</a></div>";
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_ground` 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']>0)echo "<div class='block'><img width='16' height='16' src='images/icons/water.png' alt='o'> <a href='?myfarm&water_all'>Полить все</a></div>";
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_ground` WHERE `id_user` = '$ku[id]' AND `id_plant` = '0' AND `cultivator` = '1'"),0)!=0 && $ku['seeder']>0)echo "<div class='block'><img width='16' height='16' src='images/icons/seat.png' alt='o'> <a href='?myfarm&seat_all'>Засеять все</a></div>";
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_ground` WHERE `id_user` = '$ku[id]' AND `id_plant` = '0' AND (`time` = '$time' OR `time` < '$time') AND `cultivator` = '0'"),0)!=0 && $ku['cultivator']>0)echo "<div class='block'><img width='16' height='16' src='images/icons/dig.png' alt='o'> <a href='?myfarm&cultivator_all'>Вскопать все</a></div>";


$q=mysql_query("SELECT * FROM `kolhoz_ground` WHERE `id_user` = '$ku[id]'");
while($post=mysql_fetch_array($q))
{
echo "";
if($post['id_plant']!=0 && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_plant` WHERE `id` = '$post[id_plant]'"),0)!=0)$plant=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_plant` WHERE `id` = '$post[id_plant]'"));

echo "<div class='block'>";
echo "".(!isset($plant)?"<span class='title'>".($post['cultivator']==1?"<img width='16' height='16' src='images/icons/seat.png' alt='o'> Земля, готовая к посеву":"<img width='16' height='16' src='images/icons/seat.png' alt='o'> Необработанная земля")."</span>":"<span  class='title'><img width='16' height='16' src='images/icons/seat.png' alt='o'> ".hsc($plant['name'])."</span>".($post['time']>$time?"<span class='small minor'> (Урожай через <span> ".time_left($post['time']-$time)."</span>)</span>":null)."")."";
if(isset($plant))
{
if($post['time']<=$time)
{
echo "<br><img width='16' height='16' src='images/icons/plants.png' alt='o'> <a href='?myfarm&harvest=$post[id]'>Собрать урожай</a>";
}
else
{
if($ku['last_soil']!=0 && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_soil` WHERE `id` = '$ku[last_soil]'"),0)!=0)$ls=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_soil` WHERE `id` = '$ku[last_soil]'"));
echo "<div class='small minor'>".($post['time_soil']<=$time && $post['soil']==0 && $post['time']>$time?"<img width='16' height='16' src='images/icons/soil.png' alt='o'> ".(isset($ls)?"<a href='?myfarm&soil=$post[id]&select=$ls[id]'>Применить
<span>".hsc($ls['name'])."</span></a>, <a href='?myfarm&change_soil'><span>выбрать
удобрение</span></a>":"<a href='?myfarm&change_soil'>Удобрить</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='images/icons/water.png'> <a href='?myfarm&water=$post[id]'>Полить</a>":null)."":null)."")."</div>";
}
}
else
{
echo "<span>";
if($ku['last_plant']!=0 && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_plant` WHERE `id` = '$ku[last_plant]'"),0)!=0)$lp=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_plant` WHERE `id` = '$ku[last_plant]'"));
echo "".($post['cultivator']==1?" ".(isset($lp)?"<br><img width='16' height='16' src='images/icons/seat.png' alt='o'> <a href='?myfarm&seat=$post[id]&select=$lp[id]'>Посадить <span>".hsc($lp['name'])."</span></a>, <a href='?myfarm&seat=$post[id]'><span>выбрать семена</span></a>":"<a href='?myfarm&seat=$post[id]'>Посадить</a>")."":"<br><img width='16' height='16' src='images/icons/dig.png' alt='o'> <a href='?myfarm&cultivator=$post[id]'><span style='title'>Вскопать</span></a>")."";
echo "</span>";
}
if(isset($plant))unset($plant);
echo "</div><div style='clear:both'></div>";
}
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_ground` WHERE `id_user` = '$ku[id]'"),0)<10)echo "<div class='block'><span class='title'>Новая земля</span><br><img width='16' height='16' src='images/icons/cart.png' alt='o'> <a href='?myfarm&new_ground'>Купить</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 `kolhoz_ground` WHERE `id_user` = '$ku[id]'"),0))."</span> золота</span></div><div style='clear:both'></div>";
//echo "";
if($ku['last_plant']!=0 && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_plant` WHERE `id` = '$ku[last_plant]'"),0)!=0)$lp=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_plant` WHERE `id` = '$ku[last_plant]'"));
if($ku['last_soil']!=0 && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_soil` WHERE `id` = '$ku[last_soil]'"),0)!=0)$ls=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_soil` WHERE `id` = '$ku[last_soil]'"));
echo "<div class='block'><img width='16' height='16' src='images/icons/seat.png' alt='o'> <a href='?myfarm&change_plant'>Сменить растение</a>: <span>".(isset($lp)?"".hsc($lp['name'])."":"-")."</span></div>";
echo "<div class='block'><img width='16' height='16' src='images/icons/soil.png' alt='o'> <a href='?myfarm&change_soil'>Сменить удобрение</a>: <span>".(isset($ls)?"".hsc($ls['name'])."":"-")."</span></div>";
echo "<div class='block'><img width='16' height='16' src='images/icons/refresh.png' alt='o'> <a href='?myfarm&reflesh=".rand(99999,99999999)."'>Обновить</a></div>";
echo "".($ku['time_cp']>$time?"<div class='block'><img width='16' height='16' src='images/icons/cross.png' alt='o'> До бесплатной очистки: <span>".time_left($ku['time_cp']-$time)."</span></div><div class='block'><span><img width='16' height='16' src='images/icons/tick.png' alt='o'> <a href='?myfarm&clean_grounds'><span>Очистить плантации</span></a></div><div class='block'>(<span>Стоимость</span>: <span><img width='16' height='16' src='images/icons/ruby.png' alt='o'> <span
class='title'>".($ku['count_cp']*10)."</span></span>)</span></div>":"<div class='block'><img width='16' height='16' src='images/icons/cross.png' alt='o'> <a href='?myfarm&clean_grounds'>Очистить плантации</a>")."</div>";
echo "</div>";
include_once 'inc/foot.php';
?>