<?
if($ku['level']<25){
echo "<div class='content'>";
echo "<div class='block'>";
echo"Доступ с 25 уровня</div></div>";
include_once 'inc/foot.php';
exit;
}
if(isset($_GET['gos']))
{
if(isset($mc))
{
if(mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_works` WHERE `id` = '$gos[id_plant]' AND (`level` = '$ku[level]' OR `level` < '$ku[level]')"),0)!=0)
mysql_querll("UPDATE `kolhoz_user` SET `last_plant` = '$gos[id_plant]' WHERE `id` = '$ku[id]'");
header("Location:?mywork");
exit;
}
else err_game("Для начала вступите в колхоз.");
}
include_once 'inc/arend.php';
include_once 'inc/money_work.php';
include_once 'inc/works_seat.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_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='img/icons/refresh.png' alt='o'> <a href='?mywork&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($ku['vetriak_time']>$time)echo "<li><img width='16' height='16' src='img/vetriak.png' alt='o'> <a class='epic' href='?shop=vetriak'>Ветряк</a><span class='minor'> на <span>".time_left($ku['vetriak_time']-$time)."</span></span></li>";
echo "<ul>";

////ГРЯДКИ


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

echo "<li><img width='48' height='48' src='".(!isset($plant)?"".($post['cultivator']==1?"img/work.png":"img/work.png")."":"img/works/$plant[id].png")."' alt='o' class='portrait'>";

echo "<div>";
echo "".(!isset($plant)?"<span class='title'>".($post['cultivator']==1?"Выберите работу":"Готов к следующей работе?")."</span>":"<span  class='title'>".hsc($plant['name'])."</span>".($post['time']>$time?"<span class='small minor'> <br/>(Конец работы через <span> ".time_left($post['time']-$time)."</span>)</span>":null)."")."";
echo "</div>";
echo "<div>";
if(isset($plant))
{
if($post['time']<=$time)
{
echo "<img width='16' height='16' src='img/icons/money.png' alt='o'> <a href='?mywork&harvest=$post[id]'>Получить оплату</a>";
}
}
else
{
echo "<span>";
if($ku['last_work']!=0 && mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_works` WHERE `id` = '$ku[last_work]'"),0)!=0)$lp=mysql_fetch_array(mysql_querll("SELECT * FROM `kolhoz_works` WHERE `id` = '$ku[last_work]'"));
echo "".($post['cultivator']==1?"<img width='16' height='16' src='img/icons/dig.png' alt='o'> ".(isset($lp)?"<a href='?mywork&seat=$post[id]&select=$lp[id]'><span>".hsc($lp['name'])."</span></a>, <a href='?mywork&seat=$post[id]'><span>другая работа</span></a>":"<a href='?mywork&seat=$post[id]'> выбрать</a>")."":"<img width='16' height='16' src='img/icons/arend.png' alt='o'> <a href='?mywork&cultivator=$post[id]'><span style='title'>Готов!</span></a>")."";
echo "</span>";
}
if(isset($plant))unset($plant);
echo "</div><div style='clear:both'></div></li>";
}

if(mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_mest` WHERE `id_user` = '$ku[id]'"),0)<6)echo "<li><img width='48' height='48' src='img/work_clean.gif' 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='?mywork&new_work'>Купить</a> за <span class='title'><img width='16' height='16' src='img/icons/ruby.png' alt='o'><span>".cpw(mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_mest` WHERE `id_user` = '$ku[id]'"),0))."</span> рубинов</span></div><div style='clear:both'></div></li>";
 if(isset($mc))
{
echo '<br><li><img width="16" height="16" src="img/icons/heli4n.png" alt="o"> <a href="?collective='.$mc['id'].'&hangar">Вызвать вертолеты</a></li>';
}
include_once 'inc/foot.php';
?>