Файл: public_html/page/adm-payment.php
Строк: 65
<?php
if (!defined('BASE_DIR')) { exit(header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found', true)); }
if (!isset($_SESSION['user_id'])) { exit(header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found', true)); }
if (!$users_info['status']) { exit(header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found', true)); }
$obEngine->addTitleHtml('Настройки сайта');
if (isset($_GET['mode']))
{
$id = (int)$_GET['id'];
$query = $mysqli->query("SELECT t1.*, t2.login as login FROM `".PREFIX."_history_out` AS t1 LEFT JOIN `".PREFIX."_users` AS t2 ON t1.user_id = t2.id WHERE t1.status = '0' and t1.id = '".$id."'");
if ($query->num_rows)
{
$res = $query->fetch_assoc();
switch ($_GET['mode'])
{
case 'pay':
if ($res['payment'] == 'wmr')
{
if ($error == 0)
{
$mysqli->query("UPDATE `".PREFIX."_history_out` SET `status` = '1' WHERE `id` = '".$id."'");
$mysqli->query("UPDATE `".PREFIX."_users` SET `money_out` = `money_out` + '".$res['price']."' WHERE `id` = '".$res['user_id']."'");
}
}
else if ($res['payment'] == 'payeer')
{
require(BASE_DIR.'/lib/payeer/cpayeer.php');
$payeer = new CPayeer(PAYEER_WALLET, PAYEER_API_ID, PAYEER_API_KEY);
if ($payeer->isAuth())
{
$arTransfer = $payeer->transfer(array(
'curIn' => 'RUB',
'sum' => floatval($res['money']),
'curOut' => 'RUB',
'to' => $res['wallet'],
'comment' => 'Выплата пользователю '.$res['login']
));
if (!empty($arTransfer['historyId']))
{
$mysqli->query("UPDATE `".PREFIX."_history_out` SET `status` = '1' WHERE `id` = '".$id."'");
$mysqli->query("UPDATE `".PREFIX."_users` SET `money_out` = `money_out` + '".$res['price']."' WHERE `id` = '".$res['user_id']."'");
}
}
}
break;
case 'cansel':
$mysqli->query("UPDATE `".PREFIX."_users` SET `money` = `money` + '".$res['price']."' WHERE `id` = '".$res['user_id']."'");
$mysqli->query("UPDATE `".PREFIX."_history_out` SET `status` = '2' WHERE `id` = '".$id."'");
break;
default:
break;
}
}
exit(header('Location: /adm-payment.php'));
}
?>
<div id="message"><?php echo $msg = isset($_GET['msg']) ? printMessage((int)$_GET['msg']) : ''; ?></div>
<div class="wrapper">
<div class="main">
<div class="m_left">
<div class="m_title">Заказы выплат</div>
<?php
$query = $mysqli->query("SELECT `id` FROM `".PREFIX."_history_out` WHERE `status` = '0'");
$total = $query->num_rows;
$perpage = 25;
if (empty($_GET['p']) || $_GET['p'] <= 0)
{
$page = 1;
}
else
{
$page = (int)$_GET['p'];
}
$pages_count = ceil($total / $perpage);
if ($page > $pages_count) $page = $pages_count;
$start_pos = ($page - 1) * $perpage;
if ($start_pos < 0) $start_pos = 0;
$query = $mysqli->query("SELECT t1.*, t2.login as login, DATE_FORMAT(t1.time_add, '%d.%m.%y, %H:%i') as f_time_add FROM `".PREFIX."_history_out` AS t1 LEFT JOIN `".PREFIX."_users` AS t2 ON t1.user_id = t2.id WHERE t1.status = '0' LIMIT ".$start_pos.", ".$perpage."");
if ($query->num_rows)
{
?>
<table class="all_table" width="600" align="left" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="all_title">ID</td>
<td class="all_title">Дата заявки</td>
<td class="all_title">Пользователь</td>
<td class="all_title">Платёжная система</td>
<td class="all_title">Сумма</td>
<td class="all_title">Действия</td>
</tr>
<?php
$arr_paysystem = ['wmr' => 'WebMoney', 'payeer' => 'Payeer'];
while ($row = $query->fetch_assoc())
{
?>
<tr>
<td class="all_mid"><?php echo $row['id']; ?></td>
<td class="all_mid"><?php echo $row['f_time_add']; ?></td>
<td class="all_mid"><?php echo $row['login']; ?></td>
<td class="all_mid"><?php echo $arr_paysystem[$row['payment']]; ?></td>
<td class="all_mid"><?php echo $row['money']; ?></td>
<td class="all_mid">
<span class="list-group-item">
<i class="fa fa-upload fa-button fa-fw" title="Выплатить" href="/adm-payment.php?id=<?php echo $row['id']; ?>&mode=pay&p=<?php echo $page; ?>" onclick="location = $(this).attr('href');"></i>
<i class="fa fa-times-circle fa-button fa-fw" title="Отменить" href="/adm-payment.php?id=<?php echo $row['id']; ?>&mode=cansel&p=<?php echo $page; ?>" onclick="location = $(this).attr('href');"></i>
</span>
</td>
</tr>
<?php
}
?>
</table>
<?php
if ($total >= $perpage)
{
printPageNav($page, $pages_count, 'adm-users.php?refs=', $total, $perpage);
}
}
?>
</div>
<?php include 'module/user_menu.php'; ?>
</div>
</div>