<?
if($ku['level']<14)
{
echo'
<div class="event"><h1>Робота</h1></div>
<div class="content">
<div class="block">
<div class="feedback">
Робота доступна с 15 уровня!
</div></div>';
include_once 'inc/foot.php';
exit;
}
if(isset($_GET['gos']))
{
if(isset($mc))
{
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_works` WHERE `id` = '$gos[id_plant]' AND (`level` = '$ku[level]' OR `level` < '$ku[level]')"),0)!=0)
mysql_query("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';
include_once 'inc/clean_works.php';
include_once 'inc/change_works.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 class='feedback'>";
echo "<div><img width='16' height='16' src='images/icons/refresh.png' alt='o'> <a href='?mywork'>Обновить</a></div>";
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>";
echo "<ul>";
echo "<li class='pt'>";
////ГРЯДКИ
echo "</li>";

$q=mysql_query("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_query("SELECT COUNT(*) FROM `kolhoz_works` WHERE `id` = '$post[id_plant]'"),0)!=0)$plant=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_works` WHERE `id` = '$post[id_plant]'"));

echo "<li><img width='48' height='48' src='".(!isset($plant)?"".($post['cultivator']==1?"images/work.png":"images/work.png")."":"images/works/$plant[id].gif")."' 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='images/icons/money.png' alt='o'> <a href='?mywork&harvest=$post[id]'>Получить оплату</a>";
}
}
else
{
echo "<span>";
if($ku['last_work']!=0 && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_works` WHERE `id` = '$ku[last_work]'"),0)!=0)$lp=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_works` WHERE `id` = '$ku[last_work]'"));
echo "".($post['cultivator']==1?"<img width='16' height='16' src='images/icons/work_icon.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='images/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_query("SELECT COUNT(*) FROM `kolhoz_mest` WHERE `id_user` = '$ku[id]'"),0)<6)
echo "<li><img width='48' height='48' src='images/work_clean.gif' 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='?mywork&new_work'>Купить</a> за <span class='title'><img width='16' height='16' src='images/icons/ruby.png' alt='o'><span>".cph(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_mest` WHERE `id_user` = '$ku[id]'"),0))."</span> рубинов</span></div><div style='clear:both'></div></li>";
if($ku['last_plant']!=0 && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_works` WHERE `id` = '$ku[last_plant]'"),0)!=0)$lp=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_works` WHERE `id` = '$ku[last_plant]'"));
echo "".($ku['time_cp4']>$time?"<li><img width='16' height='16' src='images/icons/cross.png' alt='o'> До бесплатного увольнения: <span>".time_left($ku['time_cp4']-$time)."</span></li><li><span><img width='16' height='16' src='images/icons/tick.png' alt='o'> <a href='?mywork&clean_works'><span>Уволится</span></a>(<span>Стоимость</span>: <span><img width='16' height='16' src='images/icons/ruby.png' alt='o'> <span class='title'>".($ku['count_cp4']*10)."</span></span>)</span></li>":"<li><img width='16' height='16' src='images/icons/cross.png' alt='o'> <a href='?mywork&clean_works'>Уволится</a></li>")."</ul>";
 if(isset($mc))
{
echo '<br><li><img width="16" height="16" src="images/icons/heli4n.png" alt="o"> <a href="?collective='.$mc['id'].'&hangar">Вызвать вертолеты</a></li>';
}
echo '</div>';
include_once 'inc/foot.php';

?>