<script language="javascript" type="text/javascript" src="files/alt.js"></script>
<?php
$s = $_GET['s'];
if($s == 2) {
print "<p class=\"y13w\">Показать: <a href=\"?a=editop&s=2\"><u>Пополнение счёта</u></a> <a href=\"?a=editop&s=1\">Вывод со счёта</a></p>";
?>
<div align="right" class="y13w">
<a href="?a=editop&s=2&sort=1">В процессе</a>
<a href="?a=editop&s=2">Выполненые</a>
</div>
<?php
if ($_GET['action'] == 'clean') {
$postvar = array_keys($_POST);
$count = 0;
while($count < count($postvar)) {
$sid = $_POST[$postvar[$count]];
$query = 'UPDATE enter SET status = 5 WHERE id = '.$sid.' LIMIT 1';
$query_res = mysql_query($query);
$count++;
}
}
if (isset($_GET['sort'])) {
$sort = $_GET['sort'];
} else {
$sort = 0;
}
function topics_list($page, $num, $status, $query)
{
?>
<table align="center" width="100%" border="0" cellpadding="1" cellspacing="1" class="graph">
<tr align="center" height="19">
<td width="150"><b>Дата</b></td>
<td><b>Логин</b></td>
<td width="100"><b>Сумма</b></td>
<td width="120"><b>Кошелёк</b></td>
<td width="70"><b>Статус</b></td>
</tr>
<form action='?a=editop&s=2&sort=<?php print $_GET[sort]; ?>&action=clean' method='post'>
<?php
$result = mysql_query($query);
$themes = mysql_num_rows($result);
$total = intval(($themes - 1) / $num) + 1;
if (empty($page) or $page < 0) $page = 1;
if ($page > $total) $page = $total;
$start = $page * $num - $num;
$result = mysql_query($query.' LIMIT '.$start.', '.$num);
while ($topics = mysql_fetch_array($result))
{
print '<tr align="center" >
<td><input type="checkbox" name="box'.$topics['id'].'" value="'.$topics['id'].'" /> '.date("d.m.Y H:i:s", $topics['date']).'</td>
<td align="left"><b>'.$topics['login'].'</b></td>
<td>'.$topics['sum'].'</td>
<td>'.$topics['wmz'].'</td>
<td>'.$topics['status'].'</td></tr>';
}
?>
<tr><td><input class="input dfs3" type="submit" border="0" value="Очистить" title="Очистить"></td></tr>
</form>
</table>
<?php
if ($page != 1) $pervpage = "<a href=?a=editop&s=2&sort=".$_GET['sort']."&page=". ($page - 1) .">«</a>";
if ($page != $total) $nextpage = " <a href=?a=editop&sort=".$_GET['sort']."&s=2&page=". ($page + 1) .">»</a>";
if ($page - 2 > 0) $page2left = " <a href=?a=editop&s=2&sort=".$_GET['sort']."&page=". ($page - 2) .">". ($page - 2) ."</a> | ";
if ($page - 1 > 0) $page1left = " <a href=?a=editop&s=2&sort=".$_GET['sort']."&page=". ($page - 1) .">". ($page - 1) ."</a> | ";
if ($page + 2 <= $total) $page2right = " | <a href=?a=editop&s=2&sort=".$_GET['sort']."&page=". ($page + 2) .">". ($page + 2) ."</a>";
if ($page + 1 <= $total) $page1right = " | <a href=?a=editop&s=2&sort=".$_GET['sort']."&page=". ($page + 1) .">". ($page + 1) ."</a>";
print "<b>Страницы: </b>".$pervpage.$page2left.$page1left."[".$page."]".$page1right.$page2right.$nextpage;
}
$sql = 'SELECT * FROM enter';
if($sort != 1) {
$sql .= ' WHERE status = 2 AND status != 5 ORDER BY id DESC';
} else {
$sql .= ' WHERE status != 2 AND status != 5 ORDER BY id DESC';
}
$page = intval($_GET['page']);
topics_list($page, 50, $status, $sql);
} else {
print "<p class=\"y13w\">Показать: <a href=\"?a=editop&s=2\">Пополнение счёта</a> <a href=\"?a=editop&s=1\"><u>Вывод со счёта</u></a> <a href=\"xml.php\" title=\"Сгенерировать XML-файл для массовых выплат\"><font color=\"#339900\">XML</font></a> <a href=\"?a=minusers\"><font color=\"blue\">MIN</font></a><hr /></p>";
?>
<div align="right" class="y13w"><a href="?a=editop&sort=1">Выполненные</a> <a href="?a=editop&sort=0">Невыполненные</a></div>
<?php
$action = $_GET['action'];
if($action == "setstatus") {
$id = $_GET['id'];
$query_res = 'UPDATE output SET status = 2 WHERE id='.$id.' LIMIT 1';
$query_res = mysql_query($query_res);
}
if ($_GET['action'] == 'clean') {
$postvar = array_keys($_POST);
$count = 0;
while($count < count($postvar)) {
$sid = $_POST[$postvar[$count]];
$query = 'UPDATE output SET status = 5 WHERE id = '.$sid.' LIMIT 1';
$query_res = mysql_query($query);
$count++;
}
}
if (isset($_GET['sort'])) {
$sort = $_GET['sort'];
} else {
$sort = 0;
}
function topics_list($page, $num, $status, $query, $cfgURL)
{
?>
<table align="center" width="100%" border="0" cellpadding="1" cellspacing="1" class="graph">
<tr align="center" height="19">
<td width="150"><b>Дата</b></td>
<td><b>Логин</b></td>
<td width="100"><b>Сумма</b></td>
<td width="100"><b>Перевести</b></td>
<td width="120"><b>Кошелёк</b></td>
<td width="70"><b>Действие</b></td>
</tr>
<form action='?a=editop&s=1&sort=<?php print $_GET[sort]; ?>&action=clean' method='post'>
<?php
$result = mysql_query($query);
$themes = mysql_num_rows($result);
$total = intval(($themes - 1) / $num) + 1;
if (empty($page) or $page < 0) $page = 1;
if ($page > $total) $page = $total;
$start = $page * $num - $num;
$result = mysql_query($query.' LIMIT '.$start.', '.$num);
$esum = 0.00;
$osum = 0.00;
while ($topics = mysql_fetch_array($result))
{
$perc = $topics['sum'] - $topics['sum'] / 100 * 0.8 - 0.01;
$esum = sprintf ("%01.2f", $esum + $topics['sum']);
$osum = sprintf ("%01.2f", $osum + $perc);
print '<tr align="center" >
<td><input type="checkbox" name="box'.$topics['id'].'" value="'.$topics['id'].'" /> '.date("d.m.Y H:i:s", $topics['date']).'</td>
<td align="left"><b>'.$topics['login'].'</b></td>
<td>'.$topics['sum'].'</td>
<td>'.sprintf ("%01.2f", $perc).'</td>
<td>'.$topics['wmz'].'</td>
<td>';
if (!$topics['status']) {
print '<a href="wmk:payto?Purse='.$topics['wmz'].'&Amount='.sprintf ("%01.2f", $perc).'&Desc=Out money '.$cfgURL.'. Login: '.$topics['login'].'. Date: '.date("d.m.Y H:i", $topics['date']).', order '.$topics['id'].'"><img border="0" src="images/out.gif" width="12" height="12" alt="Сделать перевод" /></a> ';
print '<a href="?a=editop&action=setstatus&id='.$topics['id'].'&l='.$topics['login'].'"><img border="0" src="images/status.gif" width="12" height="12" alt="Заявка выполнена! Убрать!" /></a> ';
}
print "<img style=\"cursor: hand;\" onclick=\"if(confirm('Вы уверены?')) top.location.href='del/output.php?id=".$topics['id']."'\"; src=\"images/del.gif\" width=\"12\" height=\"12\" border=\"0\" alt=\"Удалить\" /></td></tr>";
}
?>
<tr>
<td><input class="input dfs3" type="submit" border="0" value="Очистить" title="Очистить"></td>
<td></td>
<td align="center"><b ><?php print $esum; ?></b></td>
<td align="center"><u ><b><?php print $osum; ?></b></u></td>
<td></td>
<td></td>
</tr>
</form>
</table>
<?php
if ($page != 1) $pervpage = "<a href=?a=editop&sort=".$_GET['sort']."&page=". ($page - 1) ."><<</a>";
if ($page != $total) $nextpage = " <a href=?a=editop&sort=".$_GET['sort']."&page=". ($page + 1) .">>></a>";
if ($page - 2 > 0) $page2left = " <a href=?a=editop&sort=".$_GET['sort']."&page=". ($page - 2) .">". ($page - 2) ."</a> | ";
if ($page - 1 > 0) $page1left = " <a href=?a=editop&sort=".$_GET['sort']."&page=". ($page - 1) .">". ($page - 1) ."</a> | ";
if ($page + 2 <= $total) $page2right = " | <a href=?a=editop&sort=".$_GET['sort']."&page=". ($page + 2) .">". ($page + 2) ."</a>";
if ($page + 1 <= $total) $page1right = " | <a href=?a=editop&sort=".$_GET['sort']."&page=". ($page + 1) .">". ($page + 1) ."</a>";
print "<b>Страницы: </b>".$pervpage.$page2left.$page1left."[".$page."]".$page1right.$page2right.$nextpage;
}
$sql = 'SELECT * FROM output';
switch ($sort)
{
case 0:
$sql .= ' WHERE status = 0 ORDER BY id DESC';
break;
case 1:
$sql .= ' WHERE status = 2 ORDER BY id DESC';
break;
}
$page = intval($_GET['page']);
topics_list($page, 50, $status, $sql, $cfgURL);
}
?>