<?
if(isset($_GET['gos']))
{
if(isset($mc))
{
if(mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_tree` WHERE `id` = '$gos[id_tree]' AND (`level` = '$ku[level]' OR `level` < '$ku[level]')"),0)!=0)
mysql_querll("UPDATE `kolhoz_user` SET `last_tree` = '$gos[id_tree]' WHERE `id` = '$ku[id]'");
header("Location:?mygarden");
exit;
}
else err_game("Для начала вступите в колхоз.");
}
include_once 'inc/change_tree.php';
include_once 'inc/change_isoil.php';
include_once 'inc/plug_all.php';
include_once 'inc/plug.php';
include_once 'inc/sbor_all.php';
include_once 'inc/sbor.php';
include_once 'inc/iseat_all.php';
include_once 'inc/iseat.php';
include_once 'inc/isoil_all.php';
include_once 'inc/isoil.php';
include_once 'inc/harv_all.php';
include_once 'inc/harv.php';
include_once 'inc/clean_sad.php';
include_once 'inc/new_sad.php';
echo "<div class='event'><h1>Сады</h1></div>";
if(isset($_SESSION['cp']))
{
echo "<div class='feedback'><ul class='feedbackPanel'><li class='feedbackPanelINFO'><span class='feedbackPanelINFO'>Бесплатная очистка грядок будет доступна через ".time_left($ku['time_cp3']-$time)."</span></li></ul></div>";
unset($_SESSION['cp']);
}
echo "<div class='content'>";
echo "<div class='block'>";
echo "<div><img width='16' height='16' src='img/icons/refresh.png' alt='o'> <a href='?mygarden&reflesh=".rand(99999,99999999)."'>Обновить</a></div>";
if($ku['hydropinics_time']>$time)echo "<li><img width='16' height='16' src='img/icons/hydropinics.png' alt='o'> <a class='epic' href='?shop=hydropinics'>Гидропоника</a><span class='minor'> $ku[hydropinics_type]% на <span>".time_left($ku['hydropinics_time']-$time)."</span></span></li>";
if($ku['scarecrow_time']>$time)echo "<li><img width='16' height='16' src='img/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='img/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='img/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='img/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(mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_sad` WHERE `id_user` = '$ku[id]' AND (`time` < '$time' OR `time` = '$time') AND `id_tree` != '0'"),0)!=0 && $ku['conveyer']>0)echo "<div><img width='16' height='16' src='img/icons/conveyer.png' alt='o'> <a href='?mygarden&sbor_all'>Продать все</a></div>";
if(mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_sad` WHERE `id_user` = '$ku[id]' AND `soil` = '0' AND (`time_soil` = '$time' OR `time_soil` < '$time') AND `id_tree` != '0' AND `time` > '$time'"),0)!=0 && $ku['soiler']>0)echo "<div><img width='16' height='16' src='img/icons/isoil.png' alt='o'> <a href='?mygarden&isoil_all'>Удобрить все</a></div>";
if(mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_sad` WHERE `id_user` = '$ku[id]' AND `id_tree` != '0' AND (`time_sbor` = '$time' OR `time_sbor` < '$time') AND `time` > '$time' AND (`soil` = '0' AND `time_soil` > '$time' OR `soil` = '1')"),0)!=0 && $ku['harvester']>0)echo "<div><img width='16' height='16' src='img/icons/harv.png' alt='o'> <a href='?mygarden&harv_all'>Собрать урожай</a></div>";
if(mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_sad` WHERE `id_user` = '$ku[id]' AND `id_tree` = '0' AND `plug` = '1'"),0)!=0 && $ku['iseeder']>0)echo "<div><img width='16' height='16' src='img/icons/iseat.png' alt='o'> <a href='?mygarden&iseat_all'>Засадить все</a></div>";
if(mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_sad` WHERE `id_user` = '$ku[id]' AND `id_tree` = '0' AND (`time` = '$time' OR `time` < '$time') AND `plug` = '0'"),0)!=0 && $ku['plug']>0)echo "<div><img width='16' height='16' src='img/icons/dig.png' alt='o'> <a href='?mygarden&plug_all'>Вскопать все</a></div>";
echo "<ul>";

////ГРЯДКИ


$q=mysql_querll("SELECT * FROM `kolhoz_sad` WHERE `id_user` = '$ku[id]'");
while($post=mysql_fetch_array($q))
{
echo "<li>";
if($post['id_tree']!=0 && mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_tree` WHERE `id` = '$post[id_tree]'"),0)!=0)$tree=mysql_fetch_array(mysql_querll("SELECT * FROM `kolhoz_tree` WHERE `id` = '$post[id_tree]'"));

echo "<li><img width='48' height='48' src='".(!isset($tree)?"".($post['plug']==1?"img/dirt_new.jpg":"img/dirt2_new.jpg")."":"img/tree/$tree[id].png")."' alt='o' class='portrait'>";
echo "<div>";
echo "".(!isset($tree)?"<span class='title'>".($post['plug']==1?"Земля, готовая к посеву":"Необработанная земля")."</span>":"<span  class='title'>".hsc($tree['name'])."</span>".($post['time']>$time?"<span class='small minor'> (Высохнет через <span> ".time_left($post['time']-$time)."</span>)</span>":null)."")."";
echo "</div>";
echo "<div>";
if(isset($tree))
{
if($post['time']<=$time)
{
echo "<img width='16' height='16' src='img/icons/conveyer.png' alt='o'> <a href='?mygarden&sbor=$post[id]'>Продать дерево</a>";
}
else
{
if($ku['last_soil3']!=0 && mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_soil` WHERE `id` = '$ku[last_soil3]'"),0)!=0)$ls=mysql_fetch_array(mysql_querll("SELECT * FROM `kolhoz_soil` WHERE `id` = '$ku[last_soil3]'"));
echo "<div class='small minor'>".($post['time_soil']<=$time && $post['soil']==0 && $post['time']>$time?"<img width='16' height='16' src='img/icons/isoil.png' alt='o'> ".(isset($ls)?"<a href='?mygarden&isoil=$post[id]&select=$ls[id]'>Применить
<span>".hsc($ls['name'])."</span></a>, <a href='?mygarden&isoil=$post[id]'><span>выбрать
удобрение</span></a>":"<a href='?mygarden&isoil=$post[id]'>Удобрить</a>")."":"".($post['soil']==0 && $post['time']>$time?"Удобрение через ".time_left($post['time_soil']-$time)."":null)."")."</div>";
echo "<div class='small minor'>".($post['time_sbor']>$time && $post['time']>$time?"Урожай через ".time_left($post['time_sbor']-$time)."":"".($post['time']>$time?"".($post['soil']==0 && $post['time_soil']>$time || $post['soil']==1?"<img alt='' width='16' height='16' src='img/icons/harv.png'> <a href='?mygarden&harv=$post[id]'>Собрать</a>":null)."":null)."")."</div>";
}
}
else
{
echo "<span>";
if($ku['last_tree']!=0 && mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_tree` WHERE `id` = '$ku[last_tree]'"),0)!=0)$lp=mysql_fetch_array(mysql_querll("SELECT * FROM `kolhoz_tree` WHERE `id` = '$ku[last_tree]'"));
echo "".($post['plug']==1?"<img width='16' height='16' src='img/icons/iseat.png' alt='o'> ".(isset($lp)?"<a href='?mygarden&iseat=$post[id]&select=$lp[id]'>Посадить <span>".hsc($lp['name'])."</span></a>, <a href='?mygarden&iseat=$post[id]'><span>выбрать дерево</span></a>":"<a href='?mygarden&iseat=$post[id]'>Посадить</a>")."":"<img width='16' height='16' src='img/icons/plug.png' alt='o'> <a href='?mygarden&plug=$post[id]'><span style='title'>Вскопать</span></a>")."";
echo "</span>";
}
if(isset($tree))unset($tree);
echo "</div><div style='clear:both'></div></li>";
}
if(mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_sad` WHERE `id_user` = '$ku[id]'"),0)<20)echo "<li><img width='48' height='48' src='img/dirt_new.jpg' 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='?mygarden&new_sad'>Купить</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_sad` WHERE `id_user` = '$ku[id]'"),0))."</span> рубинов</span></div><div style='clear:both'></div></li>";
//echo "</ul>";
if($ku['last_tree']!=0 && mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_tree` WHERE `id` = '$ku[last_tree]'"),0)!=0)$lp=mysql_fetch_array(mysql_querll("SELECT * FROM `kolhoz_tree` WHERE `id` = '$ku[last_tree]'"));
if($ku['last_soil3']!=0 && mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_soil` WHERE `id` = '$ku[last_soil3]'"),0)!=0)$ls=mysql_fetch_array(mysql_querll("SELECT * FROM `kolhoz_soil` WHERE `id` = '$ku[last_soil3]'"));
echo "<ul class='ptm'><li><img width='16' height='16' src='img/icons/select_tree.png' alt='o'> <a href='?mygarden&change_tree'>Выбрать дерево</a>: <span>".(isset($lp)?"".hsc($lp['name'])."":"-")."</span></li>";
echo "<li><img width='16' height='16' src='img/icons/isoil.png' alt='o'> <a href='?mygarden&change_isoil'>Сменить удобрение</a>: <span>".(isset($ls)?"".hsc($ls['name'])."":"-")."</span></li>";
echo "".($ku['time_cp3']>$time?"<li><img width='16' height='16' src='img/icons/cross.png' alt='o'> До бесплатной очистки: <span>".time_left($ku['time_cp3']-$time)."</span></li><li><span><img width='16' height='16' src='img/icons/clean_sad.png' alt='o'> <a href='?mygarden&clean_sad'><span>Срубить деревья</span></a> (<span>Стоимость</span>: <span><img width='16' height='16' src='img/icons/ruby.png' alt='o'> <span
class='title'>".($ku['count_cp3']*10)."</span></span>)</span></li>":"<li><img width='16' height='16' src='img/icons/clean_sad.png' alt='o'> <a href='?mygarden&clean_sad'>Срубить деревья</a></li>")."</ul>";
if(isset($mc))echo "<li class='pt'><img width='16' height='16' src='img/icons/heli4n.png' alt='o'> <a href='?collective=$mc[id]&hangar'>Вызвать вертолет</a></li>";
echo '</ul></div></div>';
include_once 'inc/foot.php';
?>
