<h1>Заказы на вывод средств</h1>
<?php
db_connect();
if(isset($_POST["id"])){
$res = db_query("SELECT `summa`, `login` FROM ".DBpref."balance_cash WHERE `id` = ".intval($_POST["id"]));
if(db_rows($res) != 0){
	$row = db_assoc($res);
	db_query("UPDATE `".DBpref."balance_cash` SET `status` = 1 WHERE `id` = ".intval($_POST["id"]));
	db_query("UPDATE `".DBpref."users` SET `balance_cash` = `balance_cash` + ".round($row["summa"] ,2)." WHERE `login` = '".db_string($row["login"])."'");
	echo "<h2>Удаленно</h2>";
	}
}
$res = db_query("SELECT `t1`.`id`, `t1`.`login`, `t1`.`summa`, `t1`.`dat`, `t2`.`wmid`, `t2`.`wmr` FROM `".DBpref."balance_cash` `t1` INNER JOIN `".DBpref."users` `t2` ON `t1`.`login` = `t2`.`login` ORDER BY `t1`.`id` DESC");
db_close();

if(db_rows($res) == 0)
	echo "<h2>Заявок нет</h2>";
	
echo '
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="table1">
  <tr>
    <td>Логин</td>
    <td>Сумма</td>
    <td>WMID</td>
    <td>WMR</td>
    <td>Дата</td>
    <td></td>
  </tr>
';
while($row = db_assoc($res)){
echo '
  <tr>
    <td>'.htmlspecialchars($row["login"]).'</td>
    <td>'.round($row["summa"], 2).'</td>
    <td>'.htmlspecialchars($row["wmid"]).'</td>
    <td>'.htmlspecialchars($row["wmr"]).'</td>
    <td>'.$row["dat"].'</td>
    <td>
	
		<form action="" method="post">
			<a href="wmk:payto?Purse='.htmlspecialchars($row["wmr"]).'&Amount='.round($row["summa"], 2).'&Desc=Оплата №'.$row["id"].' пользователю '.htmlspecialchars($row["login"]).' в размере '.round($row["summa"], 2).' руб.&BringToFront=Y"><input value="Оплатить" name="" type="button" /></a>
			<input name="id" type="hidden" value="'.$row["id"].'">
			<input name="" type="submit" value="Оплачено">
		</form>
	</td>
  </tr>
';
}
echo '
</table>
';
?>