<?
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='small ptm'>
<div style='padding-top:4px'>
<div class='event' style='height:2px'>
<div class='eventlight' style='height:2px;width:".rand(75,95)."%'>
</div>
<ul class='block'>
<li>
 <div class="content">
<div class="block">
<div>
<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';
?>