<?
if(isset($_GET['myfarm']) && isset($_GET['change_plant']))
{
echo '<div class="event"><h1>Магазин семян</h1></div>';
echo "<div class='content'>";
echo "<div class='blockings'>";
if(isset($_GET['select']) && intval($_GET['select'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_plant` WHERE `id` = '".intval($_GET['select'])."' AND (`level` = '$ku[level]' OR `level` < '$ku[level]')"),0)!=0)
{
$plant=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_plant` WHERE `id` = '".intval($_GET['select'])."'"));
mysql_query("UPDATE `kolhoz_user` SET `last_plant` = '$plant[id]' WHERE `id` = '$ku[id]'");
header("Location:?myfarm&".passgen());
exit;
}
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_plant`"),0);
if ($k_post==0)
{
echo "Список пуст...";
}
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
$q=mysql_query("SELECT * FROM `kolhoz_plant` ORDER BY `level` ASC LIMIT $start, $set[p_str]");
echo "<ul>";
while($post=mysql_fetch_array($q))
{
$labmo=mysql_fetch_array(mysql_query("SELECT *  FROM `kolhoz_lab_m` WHERE `id_user` = '$ku[id]'"));
$labo=mysql_fetch_array(mysql_query("SELECT *  FROM `kolhoz_lab_o` WHERE `id_user` = '$ku[id]'"));
$labto=mysql_fetch_array(mysql_query("SELECT *  FROM `kolhoz_lab_t` WHERE `id_user` = '$ku[id]'"));
echo "<li style='padding-bottom:8px'>";
echo "<img width='48' height='48' src='img/plants/$post[id].png' alt='o' class='portrait'>";
echo "<div class='small'>";
$id=$post[id]-4;
echo "".($ku['level']>=$post['level']?"<a href='?myfarm&change_plant&select=$post[id]'>":null)."<span>".hsc($post['name'])."</span>".($ku['level']>=$post['level']?"</a>":null)." <span class='minor'>, ".($ku['level']>=$post['level']?"цена: </span><span><img width='16' height='16' src='img/icons/money.png' alt='o'><span class='title'>$post[cena]</span></span>":"доступно с $post[level] уровня</span>")."</div><div class='small minor'> Время созревания: 
<span class='title'>".(time_left($post['time']-($post['time']/100)*$labto[$id]))."</span>, Время до удобрения: <span class='title'>".time_left($post['time_soil'])."</span><br>Доход: <img width='16' height='16' src='img/icons/money.png' alt='o'> <span>".(floor(($post[money]/100)*$labmo[$id]*5+($post[money])))."</span>, Опыт: <img width='16' height='16' src='img/icons/experience.png' alt='o'> <span>".(floor(($post[rating]/100)*$labo[$id]*5+($post[rating])))."  </span>, Урожай: <span>$post[count]</span> <span>шт.</span></div></li>";
}
echo "</ul>";
if ($k_page>1)str("?myfarm&change_plant&",$k_page,$page); // Вывод страниц
echo "</div>";
include_once 'inc/foot.php';
}
?>