<?
if(isset($_GET['gos']))
{
if(isset($mc))
{
mysql_query("UPDATE `kolhoz_user` SET `last_recipes` = '$gos[id_plant2]' WHERE `id` = '$ku[id]'");
header("Location:?mycellar");
exit;
}
else err_game("Для начала вступите в колхоз.");
}
include_once 'inc/change_recipes.php';
include_once 'inc/change_soil2.php';
include_once 'inc/clean_all.php';
include_once 'inc/clean.php';
include_once 'inc/sell_all.php';
include_once 'inc/sell.php';
include_once 'inc/put_all.php';
include_once 'inc/put.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_polka.php';
include_once 'inc/new_polka.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'>Полки теперь свободны, но сначала протрите их</span></li></ul></div>";
unset($_SESSION['cp']);
}
if(isset($_GET['off']))
{
mysql_query("UPDATE `kolhoz_user` SET `kompact` = '1' WHERE `id` = '$ku[id]'");
header("Location:/?mycellar");
exit;
}
echo "<div class='content'>";
echo "<div class='block'>";
echo "<div class='feedback'>";
if($ku['time_vetruk']>$time)echo "<img width='16' height='16' src='images/vetriak.png' alt='o'> <a class='epic' href='?shop=vetriak'>Ветряк</a><span class='minor'> на <span>".time_left($ku['time_vetruk']-$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_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>";
if($ku['worker1_time']>$time)echo "<li><img width='16' height='16' alt='' src='images/icons/worker".$ku['worker1'].".png'> <a class='epic' href='?shop=worker1&id=".$ku['worker1']."'>".$namew."</a><span class='minor'> на <span>".time_left($ku['worker1_time']-$time)."</span></span></li>";
echo "<li><img src='images/icons/up.png'><a href='?mycellar&off'> Компактный вид</a></li>";
echo "<div><img width='16' height='16' src='images/icons/refresh.png' alt='o'> <a href='?mycellar&reflesh=".rand(99999,99999999)."'>Обновить</a></div>";
echo "<ul>";
echo "<li class='pt'>";
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_polka` WHERE `id_user` = '$ku[id]' AND (`time` < '$time' OR `time` = '$time') AND `id_recipes` != '0'"),0)!=0 && $ku['level']>1)echo "<div><img width='16' height='16' src='images/icons/money.png' alt='o'> <a href='?mycellar&sell_all'>Продать всё</a></div>";
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_polka` WHERE `id_user` = '$ku[id]' AND `id_recipes` = '0' AND `clean` = '1'"),0)!=0 && $ku['level']>1)echo "<div><img width='16' height='16' src='images/icons/cellar_put.png' alt='o'> <a href='?mycellar&put_all'>Заготовить все</a></div>";
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_polka` WHERE `id_user` = '$ku[id]' AND `id_recipes` = '0' AND (`time` = '$time' OR `time` < '$time') AND `clean` = '0'"),0)!=0 && $ku['level']>1)echo "<div><img width='16' height='16' src='images/icons/clear.png' alt='o'> <a href='?mycellar&clean_all'>Протереть всё</a></div>";
echo "</li>";
////Полки


$q=mysql_query("SELECT * FROM `kolhoz_polka` WHERE `id_user` = '$ku[id]'");
while($post=mysql_fetch_array($q))
{
echo "<li>";
if($post['id_recipes']!=0 && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_recipes` WHERE `id` = '$post[id_recipes]'"),0)!=0)$recipes=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_recipes` WHERE `id` = '$post[id_recipes]'"));

echo "<li><img width='48' height='48' src='".(!isset($recipes)?"".($post['clean']==1?"images/polka.png":"images/polka.png")."":"images/polka/$recipes[image].png")."' alt='o' class='portrait'>";
echo "<div>";
echo "".(!isset($recipes)?"<span class='title'>".($post['clean']==1?"Чистая полка":"Пыльная полка")."</span>":"<span  class='title'>".hsc($recipes['name'])."</span>".($post['time']>$time?"<span class='small minor'> (Будет готово через <span> ".time_left($post['time']-$time)."</span>)</span>":null)."")."";
echo "</div>";
echo "<div>";
if(isset($recipes))
{
if($post['time']<=$time)
{
echo "<img width='16' height='16' src='images/icons/money.png' alt='o'> <a href='?mycellar&sell=$post[id]'>Продать</a>";
}
else
{
if($ku['last_soil2']!=0 && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_soil2` WHERE `id` = '$ku[last_soil2]'"),0)!=0)$ls=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_soil2` WHERE `id` = '$ku[last_soil2]'"));
}
}
else
{
echo "<span>";
if($ku['last_recipes']!=0 && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_recipes` WHERE `id` = '$ku[last_recipes]'"),0)!=0)$lp=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_recipes` WHERE `id` = '$ku[last_recipes]'"));
echo "".($post['clean']==1?"<img width='16' height='16' src='images/icons/cellar_put.png' alt='o'> ".(isset($lp)?"<a href='?mycellar&put=$post[id]&select=$lp[id]'>Заготовить <span>".hsc($lp['name'])."</span></a> <a href='?mycellar&put=$post[id]'><span></span></a>":"<a href='?mycellar&put=$post[id]'>Заготовить</a>")."":"<img width='16' height='16' src='images/icons/clear.png' alt='o'> <a href='?mycellar&clean=$post[id]'><span style='title'>Протереть</span></a>")."";
echo "</span>";
}
if(isset($recipes))unset($recipes);
echo "</div><div style='clear:both'></div></li>";
}
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_polka` WHERE `id_user` = '$ku[id]'"),0)<20)echo "<li><img width='48' height='48' src='images/polka.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='?mycellar&new_polka'>Купить</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_polka` WHERE `id_user` = '$ku[id]'"),0))."</span> рубинов</span></div><div style='clear:both'></div></li>";
//echo "</ul>";
if($ku['last_recipes']!=0 && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_recipes` WHERE `id` = '$ku[last_recipes]'"),0)!=0)$lp=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_recipes` WHERE `id` = '$ku[last_recipes]'"));
if($ku['last_soil2']!=0 && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_soil2` WHERE `id` = '$ku[last_soil2]'"),0)!=0)$ls=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_soil2` WHERE `id` = '$ku[last_soil2]'"));
echo "".($ku['time_cp2']>$time?"<li><img width='16' height='16' src='images/icons/cross.png' alt='o'> До бесплатной очистки: <span>".time_left($ku['time_cp']-$time)."</span></li><li><span><img width='16' height='16' src='images/icons/tick.png' alt='o'> <a href='?mycellar&clean_polka'><span>Очистить полки</span></a>(<span>Стоимость</span>: <span><img width='16' height='16' src='images/icons/ruby.png' alt='o'> <span
class='title'>".($ku['count_cp2']*10)."</span></span>)</span></li>":"<li><img width='16' height='16' src='images/icons/cross.png' alt='o'> <a href='?mycellar&clean_polka'>Очистить полки</a></li>")."</ul>";
echo " <li><img width='16' height='16' src='images/icons/last_recipes.png' alt='o'> <a href='?mycellar&change_recipes'>Последняя заготовка</a>: <span>".(isset($lp)?"".hsc($lp['name'])."":"отсутствует")."</span></li>";
echo "<li><img width='16' height='16' src='images/icons/book.png' alt='o'> <a href='?help=recipes'>Книга рецептов</a></li>";
echo "<li><img width='16' height='16' src='images/icons/rules.png' alt='o'> <a href='?cellar_info'>Описание</a></li>";
if(isset($mc))echo "<li class='pt'><img width='16' height='16' src='images/icons/heli4n.png' alt='o'> <a href='?collective=$mc[id]&hangar'>Вызвать вертолет</a></li>";
echo '</ul></div></div>';
include_once 'inc/foot.php';
?>