<?php
if (!defined('webid')) {
    exit();
}
?>
<h3 style="border-bottom: 1px dotted #cccccc; color: #1c62b9; text-shadow: 0 1px 0 #fafafa;">История выплат</h3>
<?
mysql_query("DELETE FROM tb_history WHERE amount < 0.001"); /// Удаляем выплаты с нулем
$res = mysql_fetch_array( mysql_query("SELECT (SELECT sum(amount) FROM tb_history WHERE date > '$nowtime' - 86400) newtopaid, (SELECT count(*) FROM tb_history WHERE date > '$nowtime' - 86400) kolpaid"));
if ( $viplatak=$res["newtopaid"] > 0 ) {
    $viplatak=round($res["newtopaid"],3);
	} else {
	$viplatak = 0;
	}
$viplataks=$res["kolpaid"];
?>
<center>Всего выплачено за 24 часа: <b><?=$viplatak?></b> руб. ( <?=$viplataks?> выплат) </center><br />
<center>Последние 50 выплат:</center><br />
<table class="otab" width="100%" border="0" cellpadding="0" cellspacing="1">
    <thead>
        <th style="background: #ebebeb; padding: 3px;">Пользователь</th>
        <th style="background: #ebebeb; padding: 3px;" width="100">Дата</th>
        <th style="background: #ebebeb; padding: 3px;" width="100">Сумма</th>
        <th style="background: #ebebeb; padding: 3px;" width="100">Метод</th>
    </thead>
<?
$viplata = mysql_query("SELECT * FROM tb_history ORDER BY id DESC LIMIT 50");
while ($row = mysql_fetch_array($viplata)) {
    $nameuser = mysql_fetch_array(mysql_query("SELECT username FROM tb_users WHERE id = '$row[user]'"));
    ?>
    <tr>
        <td class="rt" align="left"><?=$nameuser['username']?></td>
        <td class="lt" align="center"><?=date('d.m.Y', $row['date'])?></td>
        <td class="rt" align="center"><?=$row['amount']?></td>
        <td class="lt" align="center"><?=$row['method']?></td>
    </tr>
    <?
}
?>
</table>