<div class="cl-right"><div class="s-bk-lf">
	<div class="acc-title">Тюрьма поросят</div><br>
</div><center>
<img src="/img/personik.png">
</center>

<?PHP
$_OPTIMIZATION["title"] = "Аккаунт - Сбор/Продажа поросят";
$usid = $_SESSION["user_id"];
$usname = $_SESSION["user"];

$db->Query("SELECT * FROM db_users_b WHERE id = '$usid' LIMIT 1");
$user_data = $db->FetchArray();

$db->Query("SELECT * FROM db_config WHERE id = '1' LIMIT 1");
$sonfig_site = $db->FetchArray();

	if(isset($_POST["sbor"])){
	
		if($user_data["last_sbor"] < (time() - 600) ){
		
			$tomat_s = $func->SumCalc($sonfig_site["a_in_h"], $user_data["a_t"], $user_data["last_sbor"]);
			$straw_s = $func->SumCalc($sonfig_site["b_in_h"], $user_data["b_t"], $user_data["last_sbor"]);
			$pump_s = $func->SumCalc($sonfig_site["c_in_h"], $user_data["c_t"], $user_data["last_sbor"]);
			$peas_s = $func->SumCalc($sonfig_site["d_in_h"], $user_data["d_t"], $user_data["last_sbor"]);
			$pean_s = $func->SumCalc($sonfig_site["e_in_h"], $user_data["e_t"], $user_data["last_sbor"]);
			$snow_s = $func->SumCalc($sonfig_site["f_in_h"], $user_data["f_t"], $user_data["last_sbor"]);
			$db->Query("UPDATE db_users_b SET 
			a_b = a_b + '$tomat_s', 
			b_b = b_b + '$straw_s', 
			c_b = c_b + '$pump_s', 
			d_b = d_b + '$peas_s', 
			e_b = e_b + '$pean_s', 
			f_b = f_b + '$snow_s', 
			all_time_a = all_time_a + '$tomat_s',
			all_time_b = all_time_b + '$straw_s',
			all_time_c = all_time_c + '$pump_s',
			all_time_d = all_time_d + '$peas_s',
			all_time_e = all_time_e + '$pean_s',
			all_time_f = all_time_f + '$snow_s',
			last_sbor = '".time()."' 
			WHERE id = '$usid' LIMIT 1");
			
			echo "<center><font color = 'green'><b>Вы собрали поросят!</b></font></center><BR />";
			
			$db->Query("SELECT * FROM db_users_b WHERE id = '$usid' LIMIT 1");
			$user_data = $db->FetchArray();
			
		}else echo "<center><font color = 'red'><b>Поросят можно собирать не чаще 1-го раза за 10 минут!</b></font></center><BR />";
	
	}



?>
                  <div class="silver-bk">
<p></p>
Распределение серебра при продаже: <b><font color="green"><?=100-$sonfig_site["percent_sell"]; ?>%</font></b> на счет для покупок и <b><font color="green"><?=$sonfig_site["percent_sell"]; ?>%</font></b> на вывод.<br>Курс продажи поросят: <font style="font-weight: bold;"><?=$sonfig_site["items_per_coin"]; ?> поросят = 1 монета.</font><br><font color="red"><b>Поросят можно собирать когда вам угодно, хоть раз в месяц!</b></font><br />        




<div class="clr"></div><BR />
<style>
#error {
border-color: #EE2327;
}

#good {
border-color: #23EE5B;
}

.alert {
color: #191A18;
margin: 5px 0;
padding: 8px 35px 8px 14px;
text-shadow: 0px 1px 0px rgba(255, 255, 255, 0.5);
background-color: #FCF8E3;
border: 2px solid #3Aa73D;
border-radius: 2px;
}

</style>




<style>
.block {
    background: #8DE470;
    border-radius: 0.2em;
    font-size: 1.125rem;
    position: relative;
    width: 85%;
    margin: 20px 0px 0px 220px;
    border: 1px solid #70A71A;
    margin-left: 53px;
}

.block_name {
background: linear-gradient(to top, #4DB66F 0%, #4DB66F 100%) repeat scroll 0% 0% transparent;
background: -webkit-linear-gradient(top, #4DB66F 0%, #4DB66F 100%);
background: -moz-linear-gradient(top, #4DB66F 0%, #4DB66F 100%);
background: -webkit-gradient(left top, left bottom, color-stop(0%, #4DB66F), color-stop(100%, #4DB66F));
background: -o-linear-gradient(top, #4DB66F 0%, #4DB66F 100%);
background: -ms-linear-gradient(top, #4DB66F 0%, #4DB66F 100%);

border-radius: 0.2em 0 0 0.2em;
font-size: 1.125rem;
position: relative;
margin: 1em -1px 0em -5px;
padding: 5px 15px;
    border: 1px solid #70A71A;
}

.block2 {
background: #EBFDE1;
border-radius: 4px;
font-size: 1.125rem;
position: relative;
width: 98%;
margin: 5px;
    border: 1px solid #70A71A;
}
</style>




<?PHP
# Продажа
if(isset($_POST["sell"])){

$all_items = $user_data["a_b"] + $user_data["b_b"] + $user_data["c_b"] + $user_data["d_b"] + $user_data["e_b"] + $user_data["f_b"];

	if($all_items > 0){
	
		$money_add = $func->SellItems($all_items, $sonfig_site["items_per_coin"]);
		
		$tomat_b = $user_data["a_b"];
		$straw_b = $user_data["b_b"];
		$pump_b = $user_data["c_b"];
		$pean_b = $user_data["d_b"];
		$peas_b = $user_data["e_b"];
		$snow_b = $user_data["f_b"];
		
		$money_b = ( (100 - $sonfig_site["percent_sell"]) / 100) * $money_add;
		$money_p = ( ($sonfig_site["percent_sell"]) / 100) * $money_add;
		
		# Обновляем юзверя
		$db->Query("UPDATE db_users_b SET money_b = money_b + '$money_b', money_p = money_p + '$money_p', a_b = 0, b_b = 0, c_b = 0, d_b = 0, e_b = 0, f_b = 0  
		WHERE id = '$usid'");
		
		$da = time();
		$dd = $da + 60*60*24*15;
		
		# Вставляем запись в статистику
		$db->Query("INSERT INTO db_sell_items (user, user_id, a_s, b_s, c_s, d_s, e_s, f_s, amount, all_sell, date_add, date_del) VALUES 
		('$usname','$usid','$tomat_b','$straw_b','$pump_b','$pean_b','$peas_b','$snow_b','$money_add','$all_items','$da','$dd')");
		
		echo "<center><font color = 'green'><b>Вы продали {$all_items} поросят, на сумму {$money_add} монет!</b></font></center><BR />";
		
		$db->Query("SELECT * FROM db_users_b WHERE id = '$usid' LIMIT 1");
		$user_data = $db->FetchArray();
		
	}else echo "<center><font color = 'white'><b>Вам нечего продавать :(</b></font></center><BR />";

}
?>  
  <div class="block">
	<div class="block_name">Kоличество ваших птиц: <b><?php $all_items = $user_data["a_t"] + $user_data["b_t"] + $user_data["c_t"] + $user_data["d_t"] + $user_data["e_t"] + $user_data["f_t"]; echo $all_items ?></b> </div>
<div class="block2">
<table width="100%" align="center"><tbody><tr>
<td width="90px"><img style="width: 60px; height: 60px;padding: 5px;" src="/img/1.png"></td>
<td width="120px"> <center><b style="font-size: 24px;"><?=$user_data["a_t"]; ?></b><br>Красных</center> </td>
<td width="40px"> <span style="font-size: 52px;">=</span></td>
<td width="50px"><img src="/img/yaco.png"></td>
<td width="250px"> <center><b style="font-size: 24px;"><?=$func->SumCalc($sonfig_site["a_in_h"], $user_data["a_t"], $user_data["last_sbor"]);?></b><br>Поросят</center> </td>
</tr></tbody></table></div>

<div class="block2">
<table width="100%" align="center"><tbody><tr>
<td width="90px"><img style="width: 60px; height: 60px;padding: 5px;" src="/img/2.png"></td>
<td width="120px"> <center><b style="font-size: 24px;"><?=$user_data["b_t"]; ?></b><br>Теренсов</center> </td>
<td width="40px"> <span style="font-size: 52px;">=</span></td>
<td width="50px"><img src="/img/yaco.png"></td>
<td width="250px"> <center><b style="font-size: 24px;"><?=$func->SumCalc($sonfig_site["b_in_h"], $user_data["b_t"], $user_data["last_sbor"]);?></b><br>Поросят</center> </td>
</tr></tbody></table></div>

<div class="block2">
<table width="100%" align="center"><tbody><tr>
<td width="90px"><img style="width: 60px; height: 60px;padding: 5px;" src="/img/3.png"></td>
<td width="120px"> <center><b style="font-size: 24px;"><?=$user_data["c_t"]; ?></b><br>Чаков</center> </td>
<td width="40px"> <span style="font-size: 52px;">=</span></td>
<td width="50px"><img src="/img/yaco.png"></td>
<td width="250px"> <center><b style="font-size: 24px;"><?=$func->SumCalc($sonfig_site["c_in_h"], $user_data["c_t"], $user_data["last_sbor"]);?></b><br>Поросят</center> </td> 
</tr></tbody></table></div>

<div class="block2">
<table width="100%" align="center"><tbody><tr>
<td width="90px"><img style="width: 60px; height: 60px;padding: 5px;" src="/img/4.png"></td>
<td width="120px"> <center><b style="font-size: 24px;"><?=$user_data["d_t"]; ?></b><br>Элов</center> </td>
<td width="40px"> <span style="font-size: 52px;">=</span></td>
<td width="50px"><img src="/img/yaco.png"></td>
<td width="250px"> <center><b style="font-size: 24px;"><?=$func->SumCalc($sonfig_site["d_in_h"], $user_data["d_t"], $user_data["last_sbor"]);?></b><br>Поросят</center> </td>
</tr></tbody></table></div>

<div class="block2">
<table width="100%" align="center"><tbody><tr>
<td width="90px"><img style="width: 60px; height: 60px;padding: 5px;" src="/img/5.png"></td>
<td width="120px"> <center><b style="font-size: 24px;"><?=$user_data["e_t"]; ?></b><br>Бабблсов</center> </td>
<td width="40px"> <span style="font-size: 52px;">=</span></td>
<td width="50px"><img src="/img/yaco.png"></td>
<td width="250px"> <center><b style="font-size: 24px;"><?=$func->SumCalc($sonfig_site["e_in_h"], $user_data["e_t"], $user_data["last_sbor"]);?></b><br>Поросят</center> </td>
</tr></tbody></table></div>
<div class="block2">
<table width="100%" align="center"><tbody><tr>
<td width="90px"><img style="width: 60px; height: 60px;padding: 5px;" src="/img/6.png"></td>
<td width="120px"> <center><b style="font-size: 24px;"><?=$user_data["f_t"]; ?></b><br>Бомб</center> </td>
<td width="40px"> <span style="font-size: 52px;">=</span></td>
<td width="50px"><img src="/img/yaco.png"></td>
<td width="250px"> <center><b style="font-size: 24px;"><?=$func->SumCalc($sonfig_site["f_in_h"], $user_data["f_t"], $user_data["last_sbor"]);?></b><br>Поросят</center> </td>
</tr></tbody></table></div>
	<div class="block_name">Cобрано для продажи: <b><?php $all_items = $user_data["a_b"] + $user_data["b_b"] + $user_data["c_b"] + $user_data["d_b"] + $user_data["e_b"] + $user_data["f_b"]; echo $all_items ?></b> поросят</div>
	<br>





	
</div>
	<center>
	
	<br />
	<form action="" method="post">
<input type="submit" name="sbor" value="Собрать все">
<input type="submit" name="sell" value="Продать за <?php $all_items = $user_data["a_b"] + $user_data["b_b"] + $user_data["c_b"] + $user_data["d_b"] + $user_data["e_b"] + $user_data["f_b"]; echo $all_items/100 ?> монет" style="width: 80%;">
</form>
<a href="http://birdesmine.cu.cc" target="_blank"><img style="opacity: 0.8;" src="https://image.jimcdn.com/app/cms/image/transf/dimension=320x10000:format=gif/path/s55d6f5de94352ed4/image/i9cc5dc9ef0e0123f/version/1448301675/image.gif"></a><br>
</center>
<br>

<div class="clr"></div>
</div>

							<div class="clr"></div>								<div class="clr"></div>	
							<br>
							<br>
							</div>
						<div class="clr"></div>
						
						<style>
						
.logo12 {
    background-image: url('/img/logo12.jpg');
    color: #5d3d1d;
    margin: 10px 0px 0px -10px;
    opacity: 0.9;
    height: 202px;
    background-size: 105%;
}
					</style>