<?
/*=====================#
echo '<div class="event"><h1>Ждите, проходит тест</h1></div>'."\n";
echo '<div class="content"><div class="block">'."\n";
echo 'Несколько минут'."\n";
echo '</div></div>'."\n";
include_once 'inc/foot.php';
exit;
#=====================*/

if(mysql_result(mysql_querll("SELECT COUNT(`id`) FROM `kolhoz_polka2` WHERE `id_user` = '$ku[id]'"),0)<4){
mysql_querll("INSERT INTO `kolhoz_polka2` SET `id_user` = '$ku[id]', `cultivator2` = '1'");
mysql_querll("INSERT INTO `kolhoz_polka2` SET `id_user` = '$ku[id]', `cultivator2` = '1'");
mysql_querll("INSERT INTO `kolhoz_polka2` SET `id_user` = '$ku[id]', `cultivator2` = '1'");
mysql_querll("INSERT INTO `kolhoz_polka2` SET `id_user` = '$ku[id]', `cultivator2` = '1'");
}



echo "<div class='event'><h1>Погреб</h1></div>";

if($ku['level']<35)
{
echo "<div class='content'>";echo "<div class='block'>";
echo'<img src="img/icons/owibochka.gif" alt="*"> Погреб доступны со 35-го уровня!';
include_once 'inc/foot.php';
echo "</div></div>";
exit;
}
//====
if($ku['rubies']<$cena)
{
$_SESSION['no_rubies']=$cena-$ku['rubies'];
header("Location:?safe");
exit;
}
//=====
if(isset($_GET['gos']))
{
if(isset($mc))
{
mysql_querll("UPDATE `kolhoz_user` SET `last_plant2` = '$gos[id_plant2]' WHERE `id` = '$ku[id]'");
header("Location:?mycellar");
exit;
}
else err_game("Для начала вступите в колхоз.");
}
if(isset($_GET['mycellar']) && $_GET['mycellar']=='sv')
{
mysql_querll("UPDATE `kolhoz_user` SET `sv` = '1' WHERE `id` = '$ku[id]'");
header("Location:?mycellar");
}
if(isset($_GET['mycellar']) && $_GET['mycellar']=='rv')
{
mysql_querll("UPDATE `kolhoz_user` SET `sv` = '0' WHERE `id` = '$ku[id]'");
header("Location:?mycellar");
}
include_once 'inc/change_plant2.php';
include_once 'inc/change_soil2.php';
include_once 'inc/cultivator_all2.php';
include_once 'inc/cultivator2.php';
include_once 'inc/harvest_all2.php';
include_once 'inc/harvest2.php';
include_once 'inc/seat_all2.php';
include_once 'inc/seat2.php';
include_once 'inc/soil_all2.php';
include_once 'inc/soil2.php';
include_once 'inc/water_all2.php';
include_once 'inc/water2.php';
include_once 'inc/clean_polks.php';
include_once 'inc/new_polka2.php';
if(isset($_SESSION['cp']))
{
echo "<div class='feedback'><ul class='feedbackPanel'><li class='feedbackPanelINFO'><span class='feedbackPanelINFO'>Полки теперь свободны, но сначала протрите их</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='?mycellar&reflesh=".rand(99999,99999999)."'>Обновить</a></div>";
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_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_polka2` WHERE `id_user` = '$ku[id]' AND `id_plant2` = '0' AND (`time` = '$time' OR `time` < '$time') AND `cultivator2` = '0'"),0)!=0 && $ku['cultivator2']>0)echo "<div><img width='16' height='16' src='img/icons/stop.png' alt='o'> <a href='?mycellar&cultivator_all2'>Протереть всё</a></div>";
if(mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_polka2` WHERE `id_user` = '$ku[id]' AND `id_plant2` = '0' AND `cultivator2` = '1'"),0)!=0 && $ku['seeder2']>0)echo "<div><img width='16' height='16' src='/img/icons/accept.png' alt='o'> <a href='?mycellar&seat_all2'>Поставить всё</a></div>";
if(mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_polka2` WHERE `id_user` = '$ku[id]' AND (`time` < '$time' OR `time` = '$time') AND `id_plant2` != '0'"),0)!=0 && $ku['harvester2']>0)echo "<div><img width='16' height='16' src='img/seller.png' alt='o'> <a href='?mycellar&harvest_all2'>Всё на рынок</a></div>";
if($ku['sv']==0)echo "<img width='16' height='16' src='img/icons/up.png' alt='o'> <a href='?mycellar=sv'>Свернуть</a><br>";
if($ku['sv']==1)echo "<img width='16' height='16' src='img/icons/down.png' alt='o'> <a href='?mycellar=rv'>Развернуть</a><br>";
echo "<ul>";
if($ku['sv']==1){
$q=mysql_querll("SELECT * FROM `kolhoz_polka2` WHERE `id_user` = '$ku[id]' LIMIT 1");
}else{
$q=mysql_querll("SELECT * FROM `kolhoz_polka2` WHERE `id_user` = '$ku[id]'");
}
while($post=mysql_fetch_array($q))
{
echo "<li>";
if($post['id_plant2']!=0 && mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_plant2` WHERE `id` = '$post[id_plant2]'"),0)!=0)$plant2=mysql_fetch_array(mysql_querll("SELECT * FROM `kolhoz_plant2` WHERE `id` = '$post[id_plant2]'"));

echo "<li><img width='48' height='48' src='".(!isset($plant2)?"".($post['cultivator2']==1?"img/icons/polka.png":"img/icons/polka.png")."":"img/plants/$plant2[id].png")."' alt='o' class='portrait'>";
echo "<div>";
echo "".(!isset($plant2)?"<span class='title'>".($post['cultivator2']==1?"Чистая полка":"Пыльная полка")."</span>":"<span  class='title'>".hsc($plant2['name'])."</span>".($post['time']>$time?"<span class='small minor'> (Будет готово через <span> ".time_left($post['time']-$time)."</span>)</span>":null)."")."";
echo "</div>";
echo "<div>";
if(isset($plant2))
{
if($post['time']<=$time)
{
echo "<img width='16' height='16' src='img/icons/harvest.png' alt='o'> <a href='?mycellar&harvest2=$post[id]'>На рынок</a>";
}
else
{
if($ku['last_soil2']!=0 && mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_soil2` WHERE `id` = '$ku[last_soil2]'"),0)!=0)$ls=mysql_fetch_array(mysql_querll("SELECT * FROM `kolhoz_soil2` WHERE `id` = '$ku[last_soil2]'"));
}
}
else
{
echo "<span>";
if($ku['last_plant2']!=0 && mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_plant2` WHERE `id` = '$ku[last_plant2]'"),0)!=0)$lp=mysql_fetch_array(mysql_querll("SELECT * FROM `kolhoz_plant2` WHERE `id` = '$ku[last_plant2]'"));
echo "".($post['cultivator2']==1?"<img width='16' height='16' src='img/icons/accept.png' alt='o'> ".(isset($lp)?"<a href='?mycellar&seat2=$post[id]&select=$lp[id]'>Поставить <span>".hsc($lp['name'])."</span></a> <a href='?mycellar&seat2=$post[id]'><span></span></a>":"<a href='?mycellar&seat2=$post[id]'>Поставить</a>")."":"<img width='16' height='16' src='img/icons/stop.png' alt='o'> <a href='?mycellar&cultivator2=$post[id]'><span style='title'>Протереть</span></a>")."";
echo "</span>";
}
if(isset($plant2))unset($plant2);
echo "</div><div style='clear:both'></div></li>";
}
if(mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_polka2` WHERE `id_user` = '$ku[id]'"),0)<200)echo "<li><img width='48' height='48' src='img/icons/polka.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='?mycellar&new_polka2'>Купить</a> за <span class='title'><img width='16' height='16' src='img/icons/ruby.png' alt='o'><span>".cpf(mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_polka2` WHERE `id_user` = '$ku[id]'"),0))."</span> рубинов</span></div><div style='clear:both'></div></li>";
//echo "</ul>";
if($ku['last_plant2']!=0 && mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_plant2` WHERE `id` = '$ku[last_plant2]'"),0)!=0)$lp=mysql_fetch_array(mysql_querll("SELECT * FROM `kolhoz_plant2` WHERE `id` = '$ku[last_plant2]'"));
if($ku['last_soil2']!=0 && mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_soil2` WHERE `id` = '$ku[last_soil2]'"),0)!=0)$ls=mysql_fetch_array(mysql_querll("SELECT * FROM `kolhoz_soil2` WHERE `id` = '$ku[last_soil2]'"));
echo " <li><img width='16' height='16' src='img/icons/cross.png' alt='o'> <a href='?mycellar&clean_polks'>Освободить полки</a></li>";
echo " <li><img width='16' height='16' src='img/icons/recipes.png' alt='o'> <a href='?mycellar&change_plant2'>Последняя заготовка</a>: <span>".(isset($lp)?"".hsc($lp['name'])."":"отсутствует")."</span></li>";
echo "<li><img width='16' height='16' src='img/icons/recipe_book.png' alt='o'> <a href='?help=recipes'>Книга рецептов</a></li>";
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 "</div>";
include_once 'inc/foot.php';
?>img width='16' height='16' src='img/icons/up.png' alt='o'