<?php

/*
* @package BANANA WARS
* @copyright: (c) 2017 G.P. aka Mvcshka (mvcshka@yandex.ru)
* @license: GNU General Public License version 2; see LICENSE.txt
* @files: /page/deposits.php
*
*/

if(!isset($_SESSION['id']))
{
	Header("Location: /");
	exit;
}

?>


<!-- OPEN CENTER -->
<tr>
    <td align="left" valign="top">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tbody>
                <tr>
                    <td width="284" align="left" valign="top">
                        <?php require('theme/users_block.php');?>
                    </td><!-- MENU USER -->
                    <td align="left" valign="top">
                    	<?php require('theme/menu.php'); ?>
                    	<div style="height:15px"></div>
                    	<table width="672" cellspacing="0" cellpadding="0" style="padding-left:10px;padding-right:10px;">
                        	<tbody>
								<tr></tr>
								
                            	<tr>
                                	<td align="left" valign="top">
                                    	<div style="background:url('/images/title.jpg') no-repeat center;text-align:center"><span style="background-color:#F0E8D5;padding-right:15px;padding-left:15px;font-size:18px">Ваша техника</span></div>
                                    	<br />
										<!-- Open fo content -->
										<?php

											$q = $mysql->prepare("SELECT * FROM db_farm WHERE UserId = ?");
											$q->execute(array($_SESSION['id']));
											if($q->rowCount() > 0)
											{
											while($r = $q->fetch())
											{
												$type = $r['Type'];
												$rr = (time() - $r['DateAdd']) / 60;
												$ll = GetUser('Level', $_SESSION['id']);
												$prod = intval($rr * $Dohod[$type]);
												$Golden = intval($prod / $CountGold[$type]);
												$Goldenn = intval($Golden / 100 * $PercentOut[$ll]);
												$PercSerebro = 100 - $PercentOut[$ll];
												$Serebro = intval($Golden / 100 * $PercSerebro);
												$Reuting = intval($prod * 0.1);
												$srokd = intval(($r['LastDate'] - time()) / 86400) + 1;
										?>
			<div id="load<?=$r['Uid']; ?>">
				<div id="depo<?=$r['Uid']; ?>">
										<?php if($type < 6) { ?>

										<span onclick="process('','/process/deposits.php?action=update&ident=<?=$r['Uid']; ?>','depo<?=$r['Uid']; ?> .result','depo<?=$r['Uid']; ?> .result','depo<?=$r['Uid']; ?>')">					
											<div class="update">
												<img src="/images/70.jpg"/ title="- <?=$PriceModer[$type]; ?>$ и + <?=$PriceModer[$type] * 0.5; ?>XP">
										</div>	
										</span>	

										<?php } ?>

										<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
											<tbody>
												<tr >
													<td style="width:9px;height:33px;background-image:url(/images/tables_vip_art/left_up.gif);background-repeat:no-repeat;"></td>
													<td style="background-image:url(/images/tables_vip_art/up.gif);background-repeat:repeat-x;" valign="center">
														<img src="/images/tables_vip_art/1_v.gif" style="float: left; margin-left:0px;align:absmiddle">&nbsp;
														<span style="font-size:1.2em"><b><?=$Name[$type]; ?></b></span>
														<span style="font-size:0.8em;color:#474747"></span>
													</td>
													<td style="width:9px;height:33px;background-image:url(/images/tables_vip_art/right_up.gif);background-repeat:no-repeat;"></td>
												</tr>
												<tr>
													<td style="width:7px;background-image:url(/images/tables_vip_art/left.gif);background-repeat:repeat-y;"></td>
													<td style="background-color:#faedd0;padding-top:7px">
														<table cellpadding="0" cellspacing="0" border="0" style="width:100%;padding:5px">
															<tbody>
																<tr>
																	<td style="width:10px;vertical-align:top;text-align:left;padding:2px 20px 10px 5px">
																		<img src="/images/shop/image_<?=$r['Type']; ?>.png">
																	</td>
																	<td style="padding-bottom:8px;">
																		<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
																			<tbody>

																				<tr>
																					<td style="width:50%"><span class="title cols" id="depores<?=$r['Uid']; ?>"><?=$prod; ?> шт.</span></td>
																					<td><img src="/images/tables_vip_art/1_v.gif"></td>
																				</tr>

																				<tr>
																					<td colspan="2">
																						<hr style="width:100%">
																					</td>
																				</tr>

																				<tr>
																					<td style="width:50%">Доход юнитов:</td>
																					<td>
																						<div style="font-size:1.2em;font:"><b><span id="depores<?=$r['Uid']; ?>"><?=$PercMoth[$type];?>% в месяц</span> </b>
																						</div>
																					</td>
																				</tr>

																				<tr>
																					<td colspan="2">
																						<hr style="width:100%">
																					</td>
																				</tr>

																				<tr>
																					<td style="width:50%">Опыт аккаунта:</td>
																					<td>
																						<div style="font-size:1.2em;font:"><b><span id="depoexp<?=$r['Uid']; ?>">+<?=$Reuting; ?>XP</span> </b>
																						</div>
																					</td>
																				</tr>

																				<tr>
																					<td colspan="2">
																						<hr style="width:100%">
																					</td>
																				</tr>

																				<?php if(intval(($r['LastDate'] - time()) / 86400) <= 0) { ?>

																				<tr>
																					<td colspan="2">
																						<div class="result"></div>
																						<span class="button" onclick="process('','/process/deposits.php?action=dell&ident=<?=$r['Uid']; ?>','depo<?=$r['Uid']; ?> .result','depo<?=$r['Uid']; ?> .result','depo<?=$r['Uid']; ?>')">Снести орудие</span><br/>
																						<span class="button" onclick="process('','/process/deposits.php?action=rem&ident=<?=$r['Uid']; ?>','depo<?=$r['Uid']; ?> .result','depo<?=$r['Uid']; ?> .result','depo<?=$r['Uid']; ?>')">Произвести ремонт за<img src="/images/tables_vip_art/1_v.gif" class="title-image"/><?=$Remont[$r['Uid']]; ?></span></span>																																
																					</td>
																				</tr>

																				<tr>
																					<td colspan="2">
																						<hr style="width:100%">
																					</td>
																				</tr>

																				<?php }  { ?>

																				<tr>
																					<td style="width:50%">Ремонт техники через:</td>
																					<td>
																						<div style="font-size:1.2em;font:"><b><span class="title cols" id="depoexp<?=$r['Uid']; ?>"><?=$srokd; ?> дней</span></b>
																						</div>
																					</td>
																				</tr>
																			</tbody>
																		</table>
																	</td>
																</tr>
															</tbody>
														</table>
													</td>
													<td style="width:7px;background-image:url(/images/tables_vip_art/right.gif);background-repeat:repeat-y;"></td>
												</tr>
												<tr>
													<td colspan="3" style="width:655px;height:43px;background-image:url(/images/tables_vip_art/bottom3.gif);">
														
															
															<table cellpadding="0" cellspacing="0" border="0" style="width:655px;height:43px;border-top:1px solid #bdaf8c;text-align:center">
																<tbody>
																	<tr>
																		<td style="vertical-align:middle;text-align:center;">
																			<div style="padding-top:4px; padding-left:4px; float: left;">
																				<table cellpadding="0" class="ui-button" cellspacing="0" border="0">
																					<tbody>
																						<tr>
																							<td align="left">
																							<div class="result"></div>
																							</td>
																							<td align="right">
																							
																							<button class="buy" onclick="process('','/process/deposits.php?action=sell&ident=<?=$r['Uid']; ?>','depo<?=$r['Uid']; ?> .result','depo<?=$r['Uid']; ?> .result','depo<?=$r['Uid']; ?>')">Продать ресурсы</button>
																							</td>
																						</tr>
																					</tbody>
																				</table>
																			</div>
																		</td>
																	</tr>
																</tbody>
															</table>
													
													</td>
												</tr>

											</tbody>
										</table>

										<?php } ?>
										<script type="text/javascript">$("#depo<?=$r['Uid']; ?> .profitability").height($("#depo<?=$r['Uid']; ?> .profitability").width())</script>									
								
										<!-- End fo content -->
										<div class="text">
											
											<div class="fail" id="allresult"></div>
											<script type="text/javascript">
												function stopsell() {
													$(".shop .button").hide();
												}
											</script>
										</div>
				</div>
				<?php } } else { echo '<center>У вас нет купленной техники!</center>'; } ?>
			</div>
									</td>
								</tr>

								<tr></tr>	
							</tbody>
						</table>
					</td>
				</tr>
			</tbody>
		</table>
	</td>
</tr>
<!-- CLOSE CENTER -->	