<?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/finances.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 />
                                    <!-- Описание контента -->	
<?php if(GetUser("MoneyEnter", $_SESSION['id']) < 0) { ?>	
<table border="0" width="100%" bgcolor="#aab9b4" cellpadding="0" cellspacing="1">
	<tbody>
		<tr>
			<td bgcolor="#f6f1e4" style="padding:4">
				<table border="0" cellpadding="4" cellspacing="0" width="100%">
					<tbody>
						<tr>
							<td valign="middle" width="31px"><img src="/images/icons/help.gif" width="31px" height="31px" align="left" style="margin-right:5"></td>
							<td> Для активации выплат необходимо пополнить свой счёт на 10 руб! </td>
						</tr>
					</tbody>
				</table>
			</td>
		</tr>
	</tbody>
</table>		

<?php } else { ?>
	<table style="margin: 20px auto;" width="300px" border="0" cellspacing="0" cellpadding="0" bgcolor="#E8DCC4">
    <tbody>
        <tr>
            <td height="8px" width="8px"><img width="9" height="9" src="/images/form-up-left.gif"></td>
            <td><div style="color:red;" align="center">Текущий курс : 1 руб. = <img src="/images/icons/money_dark.jpg" style="width:30px;"/> <span class="title">100</span></div></td>
            <td align="right"><img width="9" height="9" src="/images/form-up-right.gif"></td>
        </tr>
        <tr>
            <td style="padding:11px 20px" colspan="3">
			<form action="" method="post" id="fillForm" onsubmit="return false;">
                <table class="maintable" border="0" cellspacing="0" cellpadding="4">

                    <tbody>
                        <tr>
                            <td valign="top"><b>Деньги</b></td>
                            <td>
							<input style="border:1px solid #A4A4A4;" type="text" name="cash" maxlength="4" size="5" value="<?=GetUser("MoneyOut", $_SESSION['id']) / 100; ?>" placeholder="Сумма" onkeyup="fill_up()"/>	
							
							</td>
                        </tr>
                        <tr>
                            
							</td>
                        </tr>
                        
                        <tr>
                            <td colspan="2">
                                <div style="padding-top:4px; padding-left:4px; float: left;">
                                    <table cellpadding="0" class="ui-button" cellspacing="0" border="0" style="">
                                        <tbody>
                                            <tr>
                                                
                                            <td>
												<button class="button" onclick="process('fillForm','/process/vivod.php','fillForm .button','error','fill')">Вывести</button>
												<div id="error" class="error"></div>	
											</td>
                                                
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>
                                 
                            </td>
                        </tr>
                    </tbody>
				</table>
			</form>
            </td>
        </tr>
        <tr>
            <td height="8px" width="8px"><img width="9" height="9" src="/images/form-bottom-left.gif"></td>
            <td></td>
            <td align="right"><img width="9" height="9" src="/images/form-bottom-right.gif"></td>
        </tr>
    </tbody>
</table>

<?php } ?>

<?php

$q = $mysql->prepare("SELECT * FROM db_vivod WHERE UserId = ? AND Status = ? ORDER BY Uid DESC");
$q->execute(array($_SESSION['id'], '1'));
if($q->rowCount() == 0) { ?>

<div class="not" style="display:none;">Вы ещё не выводили золото</div>

<?php } else { ?>

<div class="table-level bg-dark-grey">
	<div class="w185 title fs14">ID</div>
	<div class="w185 title fs14">Логин</div>
	<div class="w185 title fs14">Сумма Gold</div>
	<div class="w185 title fs14">Сумма RUB</div>
	<div class="w185 title fs14">Время</div>
</div>

<?php

	while($row = $q->fetch())
	{
		echo '<div class="table-level">
					<div class="title w185 fs14">#'.$row['Uid'].'</div>
					<div class="title w185 fs14">'.$row['Login'].'</div>
					<div class="title w185 fs14"><img src="/images/icons/40.jpg" class="bonus"> - '.$row['SummaGold'].'</div>
					<div class="title w185 fs14">'.$row['SummaRub'].'</div>
					<div class="title w185 fs14">'.date("d.m.Y (H:i)", $row['DateAdd']).'</div>
				</div>';
	}
}
?>

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