<? include('checkcookie.php'); ?>
<h3>Запросы на выплату</h3>
<br>

<?
if (isset($_GET["id"]))
{

$id=$_GET["id"];
$option=$_GET["option"];

if ($option=="paid")
{

$username=$_POST["username"];

$tablae = mysql_query("SELECT * FROM tb_users where username='$username'"); 
$registroe = mysql_fetch_array($tablae);

$money=$_POST["money"];

$paid=$registroe["paid"];
$paid=$paid+$money;

    $query = "UPDATE tb_users SET paid='$paid' where username='$username'";
    mysql_query($query) or die(mysql_error());

$eltiempo=time();
$lafecha=date("d-m-Y",$eltiempo);

    $query = "INSERT INTO tb_history (user, date, amount, method, status) VALUES('$username','$lafecha','$money','WebMoney','Выплата сделана')";
    mysql_query($query) or die(mysql_error());

    $queryz = "DELETE FROM tb_payme WHERE id='$id'";
    mysql_query($queryz) or die(mysql_error());

unset($GLOBALS['option']);


echo "<font color=\"red\"><b>Потребительская статистика скорректирована.</b></font><br><br>";

}

if ($option=="del")
{
	$queryz = "DELETE FROM tb_payme WHERE id='$id'";
    	mysql_query($queryz) or die(mysql_error());

	echo "<font color=\"red\"><b>Потребительская статистика скорректирована.</b></font><br><br>";
}

}

?>

После оплаты отметить оплачено.
<br><br>
<table width='100%' border='0' cellpadding='0' cellspacing='0'> 
<tr>
<th width=50 align=center>№</th>
<th width=200 align=center>Имя</th>
<th width=200 align=center>WMR</th>
<th width=100 align=center>Объем оплаты</th>
<th width=150 align=center>Ip</th>
<th></th>
<th></th>
<th></th>
</tr>

<?
$res=mysql_query("select sitename, comment from tb_site where id='1'");
$res=mysql_fetch_array($res);
$sitename=$res["sitename"];
$comment=$res["comment"];
$comment=str_ireplace(":sitename:",$sitename,$comment);

$tabla = mysql_query("SELECT * FROM tb_payme ORDER BY id ASC"); 
while ($registro = mysql_fetch_array($tabla)) { 

echo "
<tr>
<td width=50 align=center>". $registro["id"] ."</td>
<td width=200 align=center>". $registro["username"] ."</td>
<td width=200 align=center>". $registro["pemail"] ."</td>
<td width=100 align=center>". $registro["money"] ."</td>
<td width=150 align=center>". $registro["ip"] ."</td>";
$text=str_ireplace(":username:",$registro["username"],$comment);
?>
<td><a href='wmk:payto?Purse=<?= $registro["pemail"] ?>&Amount=<?= $registro["money"] ?>&Desc=<?=$text ?>&BringToFront=Y'><button>&nbsp&nbsp&nbsp&nbspОплатить Клики&nbsp&nbsp&nbsp&nbsp</button></td>
<td>
<form method="post" action="adminmain.php?p=reqpay&id=<?= $registro["id"] ?>&option=paid">
<input type="hidden" name="money" value="<?= $registro["money"] ?>">
<input type="hidden" name="username" value="<?= $registro["username"] ?>">
<input type="submit" value="Оплачено" class="button">
</form>
</td>
<td>
<form method="post" action="adminmain.php?p=reqpay&id=<?= $registro["id"] ?>&option=del">
<input type="submit" value="Удалить" class="button">
</form>
</td>
</tr>

<?

}

?><b>Всего</b>: <font color='red'><b><?php include('config.php');
                                $result=mysql_query ("SELECT COUNT(*) FROM `tb_payme`");
                                echo mysql_result($result,0);
                                $sqryvar="Select sum(money) from tb_payme";
                                $iqryvar=mysql_query($sqryvar);
                                $tot1=mysql_result($iqryvar,0,0);
                                $totalmoney=$tot1;
                                mysql_close($con);?>
                                                на сумму <?
                                        if ($totalmoney > 0)
                                        {
                                        echo $totalmoney;
                                        }
                                        else
                                        {
                                        echo 0;
                                        }
                                        ?>&nbsp;руб</b></font>
</table>
</table>
