<?
if(isset($_GET['rating']) && (isset($_GET['rubies']) || isset($_GET['money'])))include_once 'inc/mr_rat_ct.php';
if(isset($_SESSION['bk'])){echo "<div class='block'>Касса успешно пополнена!</div>"; unset($_SESSION['bk']);}

echo "<div class='event'><h1><a href='?collective=$ct[id]'>".hsc($ct['name'])."</a> / Касса</h1></div>";
if(isset($_GET['rubies']) && in_array(intval($_GET['rubies']),array(100,1000,5000,10000,50000,100000,500000)))
{
$rubies=intval($_GET['rubies']);
if($ku['rubies']>=$rubies)
{
mysql_querll("UPDATE `kolhoz_collective` SET `rubies` = '".($ct['rubies']+$rubies)."' WHERE `id` = '$ct[id]'");
$ct['rubies']=$ct['rubies']+$rubies;
mysql_querll("INSERT INTO `kolhoz_collective_cash` SET `id_user` = '$ku[id]', `id_collective` = '$ct[id]', `count` = '$rubies', `type` = 'rubies', `time` = '$time'");
mysql_querll("UPDATE `kolhoz_user` SET `rubies` = '".($ku['rubies']-$rubies)."' WHERE `id` = '$ku[id]'");
$ku['rubies']=$ku['rubies']-$rubies;
}
else no_rubies($rubies-$ku['rubies']);
}
elseif(isset($_GET['money']) && in_array(intval($_GET['money']),array(1000,5000,10000,50000,100000,500000,1000000,5000000,10000000,50000000,100000000)))
{
$money=intval($_GET['money']);
if($ku['money']>=$money)
{
mysql_querll("UPDATE `kolhoz_collective` SET `money` = '".($ct['money']+$money)."' WHERE `id` = '$ct[id]'");
$ct['money']=$ct['money']+$money;
mysql_querll("INSERT INTO `kolhoz_collective_cash` SET `id_user` = '$ku[id]', `id_collective` = '$ct[id]', `count` = '$money', `type` = 'money', `time` = '$time'");
mysql_querll("UPDATE `kolhoz_user` SET `money` = '".($ku['money']-$money)."' WHERE `id` = '$ku[id]'");
$ku['money']=$ku['money']-$money;
}
else no_money($money-$ku['money']);
}
?>
<div class="content">
<div class="block">
<div>
<ul class="minor">
<li>Рубины: <span class="title"><img width="16" height="16" src="img/icons/ruby.png" alt="o"> <span class="title"><? echo $ct['rubies'];?></span></span></li>
<li>Монеты: <span class="title"><img width="16" height="16" src="img/icons/money.png" alt="o">
<span class="title"><? echo $ct['money'];?></span></span></li>
</ul>
</div>
<div>
<h3>Взносы</h3>
<ul>
<li><a href="?collective=<? echo $ct['id']."&cash".(!isset($_GET['rubies'])?"&rubies":null)."";?>">Внести в кассу <img width="16" height="16" src="img/icons/ruby.png" alt="o"> рубины</a><br>
<?
if(isset($_GET['rubies']))
{
?>
<?
if(isset($_POST['ok']) && $_POST['mdp']==$ku['mdp'] && intval($_POST['sum'])>0){
$rubies=floor($_POST['sum']);
if($ku['rubies']>=$rubies){
if($rubies>0){
mysql_querll("UPDATE `kolhoz_user` SET `rubies` = '".($ku['rubies'] - $rubies)."' WHERE `id` = '$ku[id]'");
mysql_querll("UPDATE `kolhoz_collective` SET `rubies` = '".($ct['rubies'] + $rubies)."' WHERE `id` = '$ct[id]'");
mysql_querll("INSERT INTO `kolhoz_collective_cash` SET `id_user` = '$ku[id]', `id_collective` = '$ct[id]', `count` = '$rubies', `type` = 'rubies', `time` = '$time'");
$_SESSION['bk']=1;
header("Location:?collective=$ct[id]&cash");
}
}

}?>

<?
echo "<div class='content'>";
echo "<div class='block'>";
echo "Введите количество рубинов:</span><br/><form method='post'>";
echo "<input type='text' name='sum' value=''><input type='hidden' name='mdp' value='$ku[mdp]'><br/>";
echo "<input type='submit' name='ok' value='Пополнить'>";
echo "</form></div>";
?>
<?
}
?>
</li>
<li><a href="?collective=<? echo $ct['id']."&cash".(!isset($_GET['money'])?"&money":null)."";?>">Внести в кассу <img width="16" height="16" src="img/icons/money.png" alt="o"> монеты</a><br>


<?
if(isset($_GET['money']))
{
?>
<?
if(isset($_POST['ok']) && $_POST['mdp']==$ku['mdp'] && intval($_POST['sum'])>0){
$money=floor($_POST['sum']);
if($ku['money']>=$money){
if($money>0){
$ku['money']=minus_money($money);
mysql_querll("UPDATE `kolhoz_collective` SET `money` = '".($ct['money']+$money)."' WHERE `id` = '$ct[id]'");
mysql_querll("INSERT INTO `kolhoz_collective_cash` SET `id_user` = '$ku[id]', `id_collective` = '$ct[id]', `count` = '$money', `type` = 'money', `time` = '$time'");
mysql_querll("UPDATE `kolhoz_user` SET `money` = '".($ku['money'] - $money)."' WHERE `id` = '$ku[id]'");
$_SESSION['bk']=1;
header("Location:?collective=$ct[id]&cash");	}
}
else no_money($money-$ku['money']);
}

echo "<div class='content'>";
echo "<div class='block'>";
echo "Введите количество монет:</span><br/><form method='post'>";
echo "<input type='text' name='sum' value=''><input type='hidden' name='mdp' value='$ku[mdp]'><br/>";
echo "<input type='submit' name='ok' value='Пополнить'>";
echo "</form></div>";
?>

<?
}
?>
</li>
</ul>
</div>
<div>
<h3>Плательщики</h3>
<ul>
<li><a href="?collective=<? echo $ct['id'];?>&cash&rating&rubies">Рейтинг по взносу <img width="16" height="16" src="img/icons/ruby.png" alt="o"> рубинов за всё время</a></li>
<li><a href="?collective=<? echo $ct['id'];?>&cash&rating&rubies&week">Рейтинг по взносу <img width="16" height="16" src="img/icons/clock.png" alt="o"> рубинов за неделю</a></li>
<li><a href="?collective=<? echo $ct['id'];?>&cash&rating&money">Рейтинг по взносу <img width="16" height="16" src="img/icons/money.png" alt="o"> монет</a></li>
</ul>
</div>
</div>
<? include_once 'inc/foot.php';?>