<?
if($ct['flowerbed']==0)
{
if(isset($_GET['buy']) && $mcu['status']==1)
{
$rating=0;
$cena=1000;
if($mc['rubies']>=$cena)
{
if(isset($_GET['ok']))
{
mysql_query("UPDATE `kolhoz_collective` SET `flowerbed` = '1' WHERE `id` = '$mc[id]'");
mysql_query("UPDATE `kolhoz_collective` SET `rubies` = '".($mc['rubies']-$cena)."', `rating` = '".($mc['rating']+$rating)."' WHERE `id` = '$mc[id]'");
$mc['flowerbed']=$ct['flowerbed']=1;
$mc['rating']=$mc['rating']+$rating;
$count_max=$ct['level']*10;
$time_rubies=floor(86400/$count_max);
$time_mezh=$time-$ct['time_obmen'];
$count_rubies=floor($time_mezh/$time_rubies);
if($count_rubies>$count_max)$count_rubies=$count_max;
$time_max=$ct['time_obmen']+($time_rubies*$count_max);
}
else
{
echo '<div class="event"><h1>Подтверждение</h1></div><div class="content"><ul class="block"><li><span class="title">Вы уверены?</span></li><li class="pt"><img alt="" width="16" height="16" src="images/icons/tick.png"> <a href="?collective='.$ct['id'].'&flowerbed&buy&ok"><span>Да, подтверждаю</span></a></li><li><img alt="" width="16" height="16" src="images/icons/cross.png"> <a href="?collective='.$ct['id'].'&flowerbed"><span>
Нет, отказываюсь</span></a></li></ul>';
include_once 'inc/foot.php';
}
}
else no_rubies_ct($cena-$ct['rubies']);
}
}
else
{
$count_max=$ct['level']*10;
$time_rubies=floor(86400/$count_max);
$time_mezh=$time-$ct['time_obmen'];
$count_rubies=floor($time_mezh/$time_rubies);
if($count_rubies>$count_max)$count_rubies=$count_max;
$time_max=$ct['time_obmen']+($time_rubies*$count_max);
if($ct['id']==$mc['id'] && $mcu['status']<=3)
{
if(isset($_GET['convert']) && in_array(intval($_GET['convert']),array(1,10,50,$count_rubies)) && $_GET['convert']!=0 && $count_rubies>0)
{
$rubies=intval($_GET['convert']);
$need_money=10000*$rubies;
if($ct['money']>=$need_money)
{
mysql_query("UPDATE `kolhoz_collective` SET `time_obmen` = '".($rubies==$count_max?$time:($time>=$time_max?$time-($time_rubies*($count_max-$rubies)):$ct['time_obmen']+($rubies*$time_rubies)))."', `rubies` = '".($ct['rubies']+$rubies)."', `money` = '".($ct['money']-$need_money)."' WHERE `id` = '$ct[id]'");
$count_rubies=$count_rubies-$rubies;
}
else echo "";
}
}
}

echo "<div class='event'><h1><a href='?collective=$ct[id]'>".hsc($ct['name'])."</a> / Цветник</h1></div>";
?>
<div class="content">
<div class="block">
<div>
<img width="48" height="48" src="images/guildFlowerbed.png" alt="o" class="portrait">
<span class="epic">Цветник</span> - используется для украшения колхоза.
Разбивается цветник неподалеку от сельсовета и засаживается декоративными растениями.</div>
<?
if($ct['flowerbed']==1)echo "<span>Сейчас доступно рубинов к обмену: $count_rubies из
$count_max</span>";
?>
<div style="clear:both"></div>
<h3>Эффект</h3>
<div class="title">
Разведение Цветника дает возможность
обменивать монеты из колхозной кассы на рубины в
колхозную кассу.
</div>
<?
if($mc['id']==$mcu['status']<=3)
{
if($ct['flowerbed']==1)
{
echo "<h3>Обменять на рубины</h3>\n";
echo "<div><img width='16' height='16' src='images/icons/convert.png' alt='o'> ".($count_rubies>=1?"<a href='?collective=$ct[id]&flowerbed&convert=1'>":"<span>")."Обменять".($count_rubies>=1?"</a>":"</span>")." <img width='16' height='16' src='images/icons/money.png' alt='o'> 10000 монет на <img width='16' height='16' src='images/icons/ruby.png' alt='o'> 1 рубин.<br/></div>";
echo "<div><img width='16' height='16' src='images/icons/convert.png' alt='o'> ".($count_rubies>=10?"<a href='?collective=$ct[id]&flowerbed&convert=10'>":"<span>")."Обменять".($count_rubies>=10?"</a>":"</span>")." <img width='16' height='16' src='images/icons/money.png' alt='o'> 100000 монет на <img width='16' height='16' src='images/icons/ruby.png' alt='o'> 10 рубинов.<br/></div>";
echo "<div><img width='16' height='16' src='images/icons/convert.png' alt='o'> ".($count_rubies>=50?"<a href='?collective=$ct[id]&flowerbed&convert=50'>":"<span>")."Обменять".($count_rubies>=50?"</a>":"</span>")." <img width='16' height='16' src='images/icons/money.png' alt='o'> 500000 монет на <img width='16' height='16' src='images/icons/ruby.png' alt='o'> 50 рубинов.<br/></div>";
if($count_rubies>1)echo "<div><img width='16' height='16' src='images/icons/convert.png' alt='o'> <a href='?collective=$ct[id]&flowerbed&convert=$count_rubies'>Обменять</a> <img width='16' height='16' src='images/icons/money.png' alt='o'> <span>".($count_rubies*10000)."</span> монет на <img width='16' height='16' src='images/icons/ruby.png' alt='o'> <span>$count_rubies</span> рубинов.<br/></div>";
}
else
{
echo "<span>
<img width='16' height='16' src='images/icons/tick.png' alt='o'><span>".($mc['id']==$ct['id'] && $mcu['status']==1?"<a href='?collective=$ct[id]&flowerbed&buy'>":null)."<span>Развести Цветник</span>".($mc['id']==$ct['id'] && $mcu['status']==1?"</a>":null)."</span> <span class='minor'>(<span>Стоимость</span>: <span><img width='16' height='16' src='images/icons/ruby.png' alt='o'> <span class='title'>1 тыс.</span></span>)</span></span>";
}
}
echo "<div class='pt minor'>\n
Разводить Цветник может председатель колхоза за счет средств из колхозной кассы. Обменивать
рубины могут председатель и зампреды.</div>\n";
echo "</div>";
include_once 'inc/foot.php';
?>